Skip to content

Comments

test(unit): contacts integration#12457

Open
hamza221 wants to merge 1 commit intomainfrom
chore/test/contact-integration
Open

test(unit): contacts integration#12457
hamza221 wants to merge 1 commit intomainfrom
chore/test/contact-integration

Conversation

@hamza221
Copy link
Contributor

@hamza221 hamza221 commented Feb 19, 2026

#10856
ForceSAB was removed

needs #12460

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds/updates unit tests around contacts integration behavior (notably after ForceSAB removal), covering both service-level contact lookup and controller endpoints including autocomplete caching.

Changes:

  • Added new unit tests for ContactsIntegration::getContactsWithName covering normal results, filtering, and edge cases.
  • Introduced a new ContactIntegrationControllerTest covering match, addMail, newContact, and autoComplete (cache hit/miss/invalid JSON).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 12 comments.

File Description
tests/Unit/Service/ContactsIntegrationTest.php Adds coverage for getContactsWithName mapping/filtering and empty/missing-field scenarios
tests/Unit/Controller/ContactIntegrationControllerTest.php New controller unit tests validating JSON responses and caching behavior for autocomplete

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +408 to +433
public function testGetContactsWithName(): void {
$name = 'John';
$searchResult = [
[
'UID' => 'jd',
'FN' => 'John Doe',
'EMAIL' => 'john@doe.com',
],
[
'UID' => 'js',
'FN' => 'John Smith',
'EMAIL' => ['john@smith.com', 'jsmith@example.com'],
],
];

$this->config->expects($this->once())
->method('getAppValue')
->with('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes')
->willReturn('yes');
$this->contactsManager->expects($this->once())
->method('search')
->with($name, ['FN'], [
'strict_search' => false,
'limit' => 20,
])
->willReturn($searchResult);
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mock setup for getAppValue and contactsManager->search(...) is repeated across multiple new tests (same options array, same default value parameter). Consider extracting a small helper (e.g., expectShareDialogEnumeration(string $value) and expectContactsSearch(string $term, array $result)) or using a data provider to reduce duplication and make future changes (like changing search options/limit) less error-prone.

Copilot uses AI. Check for mistakes.

$actual = $this->contactsIntegration->getContactsWithName($name);

$this->assertEquals($expected, $actual);
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These assertions compare structured arrays that include null and nested arrays. Using assertSame here (and in the other newly added tests) would make the assertions stricter and better aligned with declare(strict_types=1), catching unintended type coercions (e.g., '0' vs 0).

Copilot uses AI. Check for mistakes.

This comment was marked as outdated.

Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
@hamza221 hamza221 force-pushed the chore/test/contact-integration branch from 70a89e6 to c5259b4 Compare February 19, 2026 21:09
@hamza221 hamza221 marked this pull request as ready for review February 19, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants