diff options
author | Joas Schilling <coding@schilljs.com> | 2025-05-02 14:00:10 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2025-05-02 16:47:42 +0200 |
commit | c24f5fb256f53836727d3479e0fcf79d680ca2ca (patch) | |
tree | 97e2ee14c40ed1cf2237eacd26f69375235e8419 /tests/lib/Contacts | |
parent | 9a16e4fd1407f0490136f6cfeec184be4b219dce (diff) | |
download | nextcloud-server-test/noid/more-phpunit-10.tar.gz nextcloud-server-test/noid/more-phpunit-10.zip |
test: Finish migrating tests/Core/ to PHPUnit 10 compatible codetest/noid/more-phpunit-10
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib/Contacts')
-rw-r--r-- | tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php | 153 | ||||
-rw-r--r-- | tests/lib/Contacts/ContactsMenu/ManagerTest.php | 27 |
2 files changed, 85 insertions, 95 deletions
diff --git a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php index a3151d0b040..9097ee779d2 100644 --- a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php +++ b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php @@ -255,29 +255,27 @@ class ContactsStoreTest extends TestCase { $user2 = $this->createMock(IUser::class); $user3 = $this->createMock(IUser::class); + $calls = [ + [[$currentUser], ['group1', 'group2', 'group3']], + [[$user1], ['group1']], + [[$user2], ['group2', 'group3']], + [[$user3], ['group8', 'group9']], + ]; $this->groupManager->expects($this->exactly(4)) ->method('getUserGroupIds') - ->withConsecutive( - [$this->equalTo($currentUser)], - [$this->equalTo($user1)], - [$this->equalTo($user2)], - [$this->equalTo($user3)] - ) - ->willReturnOnConsecutiveCalls( - ['group1', 'group2', 'group3'], - ['group1'], - ['group2', 'group3'], - ['group8', 'group9'] - ); + ->willReturnCallback(function () use (&$calls): array { + $expected = array_shift($calls); + $this->assertEquals($expected[0], func_get_args()); + return $expected[1]; + }); $this->userManager->expects($this->exactly(3)) ->method('get') - ->withConsecutive( - ['user1'], - ['user2'], - ['user3'] - ) - ->willReturnOnConsecutiveCalls($user1, $user2, $user3); + ->willReturnMap([ + ['user1', $user1], + ['user2', $user2], + ['user3', $user3], + ]); $this->contactsManager->expects($this->once()) ->method('search') @@ -330,29 +328,27 @@ class ContactsStoreTest extends TestCase { $user2 = $this->createMock(IUser::class); $user3 = $this->createMock(IUser::class); + $calls = [ + [[$currentUser], ['group1', 'group2', 'group3']], + [[$user1], ['group1']], + [[$user2], ['group2', 'group3']], + [[$user3], ['group8', 'group9']], + ]; $this->groupManager->expects($this->exactly(4)) ->method('getUserGroupIds') - ->withConsecutive( - [$this->equalTo($currentUser)], - [$this->equalTo($user1)], - [$this->equalTo($user2)], - [$this->equalTo($user3)] - ) - ->willReturnOnConsecutiveCalls( - ['group1', 'group2', 'group3'], - ['group1'], - ['group2', 'group3'], - ['group8', 'group9'] - ); + ->willReturnCallback(function () use (&$calls): array { + $expected = array_shift($calls); + $this->assertEquals($expected[0], func_get_args()); + return $expected[1]; + }); $this->userManager->expects($this->exactly(3)) ->method('get') - ->withConsecutive( - ['user1'], - ['user2'], - ['user3'] - ) - ->willReturn($user1, $user2, $user3); + ->willReturnMap([ + ['user1', $user1], + ['user2', $user2], + ['user3', $user3], + ]); $this->contactsManager->expects($this->once()) ->method('search') @@ -463,29 +459,27 @@ class ContactsStoreTest extends TestCase { $user2 = $this->createMock(IUser::class); $user3 = $this->createMock(IUser::class); + $calls = [ + [[$currentUser], ['group1', 'group2', 'group3']], + [[$user1], ['group1']], + [[$user2], ['group2', 'group3']], + [[$user3], ['group8', 'group9']], + ]; $this->groupManager->expects($this->exactly(4)) ->method('getUserGroupIds') - ->withConsecutive( - [$this->equalTo($currentUser)], - [$this->equalTo($user1)], - [$this->equalTo($user2)], - [$this->equalTo($user3)] - ) - ->willReturnOnConsecutiveCalls( - ['group1', 'group2', 'group3'], - ['group1'], - ['group2', 'group3'], - ['group8', 'group9'] - ); + ->willReturnCallback(function () use (&$calls): array { + $expected = array_shift($calls); + $this->assertEquals($expected[0], func_get_args()); + return $expected[1]; + }); $this->userManager->expects($this->exactly(3)) ->method('get') - ->withConsecutive( - ['user1'], - ['user2'], - ['user3'] - ) - ->willReturnOnConsecutiveCalls($user1, $user2, $user3); + ->willReturnMap([ + ['user1', $user1], + ['user2', $user2], + ['user3', $user3], + ]); $this->knownUserService->method('isKnownToUser') ->willReturnMap([ @@ -542,16 +536,17 @@ class ContactsStoreTest extends TestCase { $user1 = $this->createMock(IUser::class); + $calls = [ + [[$currentUser], ['group1', 'group2', 'group3']], + [[$user1], ['group1']], + ]; $this->groupManager->expects($this->exactly(2)) ->method('getUserGroupIds') - ->withConsecutive( - [$this->equalTo($currentUser)], - [$this->equalTo($user1)] - ) - ->willReturnOnConsecutiveCalls( - ['group1', 'group2', 'group3'], - ['group1'] - ); + ->willReturnCallback(function () use (&$calls): array { + $expected = array_shift($calls); + $this->assertEquals($expected[0], func_get_args()); + return $expected[1]; + }); $this->userManager->expects($this->once()) ->method('get') @@ -617,29 +612,27 @@ class ContactsStoreTest extends TestCase { $user2 = $this->createMock(IUser::class); $user3 = $this->createMock(IUser::class); + $calls = [ + [[$currentUser], ['group1', 'group2', 'group3']], + [[$user1], ['group1']], + [[$user2], ['group2', 'group3']], + [[$user3], ['group8', 'group9']], + ]; $this->groupManager->expects($this->exactly(4)) ->method('getUserGroupIds') - ->withConsecutive( - [$this->equalTo($currentUser)], - [$this->equalTo($user1)], - [$this->equalTo($user2)], - [$this->equalTo($user3)] - ) - ->willReturnOnConsecutiveCalls( - ['group1', 'group2', 'group3'], - ['group1'], - ['group2', 'group3'], - ['group8', 'group9'] - ); + ->willReturnCallback(function () use (&$calls): array { + $expected = array_shift($calls); + $this->assertEquals($expected[0], func_get_args()); + return $expected[1]; + }); $this->userManager->expects($this->exactly(3)) ->method('get') - ->withConsecutive( - ['user1'], - ['user2'], - ['user3'] - ) - ->willReturnOnConsecutiveCalls($user1, $user2, $user3); + ->willReturnMap([ + ['user1', $user1], + ['user2', $user2], + ['user3', $user3], + ]); $this->knownUserService->method('isKnownToUser') ->willReturnMap([ diff --git a/tests/lib/Contacts/ContactsMenu/ManagerTest.php b/tests/lib/Contacts/ContactsMenu/ManagerTest.php index c87bb3d5147..dd6c634c740 100644 --- a/tests/lib/Contacts/ContactsMenu/ManagerTest.php +++ b/tests/lib/Contacts/ContactsMenu/ManagerTest.php @@ -65,11 +65,10 @@ class ManagerTest extends TestCase { $this->config->expects($this->exactly(2)) ->method('getSystemValueInt') - ->withConsecutive( - ['sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT], - ['sharing.minSearchStringLength', 0] - ) - ->willReturnOnConsecutiveCalls(25, 0); + ->willReturnMap([ + ['sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT, 25], + ['sharing.minSearchStringLength', 0, 0], + ]); $this->contactsStore->expects($this->once()) ->method('getContacts') ->with($user, $filter) @@ -102,11 +101,10 @@ class ManagerTest extends TestCase { $this->config->expects($this->exactly(2)) ->method('getSystemValueInt') - ->withConsecutive( - ['sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT], - ['sharing.minSearchStringLength', 0] - ) - ->willReturnOnConsecutiveCalls(3, 0); + ->willReturnMap([ + ['sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT, 3], + ['sharing.minSearchStringLength', 0, 0], + ]); $this->contactsStore->expects($this->once()) ->method('getContacts') ->with($user, $filter) @@ -138,11 +136,10 @@ class ManagerTest extends TestCase { $this->config->expects($this->exactly(2)) ->method('getSystemValueInt') - ->withConsecutive( - ['sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT], - ['sharing.minSearchStringLength', 0] - ) - ->willReturnOnConsecutiveCalls(3, 4); + ->willReturnMap([ + ['sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT, 3], + ['sharing.minSearchStringLength', 0, 4], + ]); $this->appManager->expects($this->once()) ->method('isEnabledForUser') ->with($this->equalTo('contacts'), $user) |