diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-05-02 11:35:41 +0200 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-05-02 11:35:41 +0200 |
commit | 10296ba7e50ede8eee0ed18f477eb3e67bfd5878 (patch) | |
tree | 10c4bc603b7a75060bbf96e7e152fd35216740ef /tests/lib | |
parent | 876c162df831f70a9b4ed886f35c47c9c22df5ea (diff) | |
download | nextcloud-server-10296ba7e50ede8eee0ed18f477eb3e67bfd5878.tar.gz nextcloud-server-10296ba7e50ede8eee0ed18f477eb3e67bfd5878.zip |
Fix tests, and fix Group::searchUsers to avoid duplicates
Also went back to searchUsers indexing the array by uid as it was the
previous behavior and the IGroup phpdoc does not say anything about the
keys.
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/Group/GroupTest.php | 10 | ||||
-rw-r--r-- | tests/lib/Group/ManagerTest.php | 6 |
2 files changed, 10 insertions, 6 deletions
diff --git a/tests/lib/Group/GroupTest.php b/tests/lib/Group/GroupTest.php index 99389880383..ac648fd7b4b 100644 --- a/tests/lib/Group/GroupTest.php +++ b/tests/lib/Group/GroupTest.php @@ -310,7 +310,7 @@ class GroupTest extends \Test\TestCase { $users = $group->searchUsers('2'); $this->assertEquals(1, count($users)); - $user2 = $users['user2']; + $user2 = reset($users); $this->assertEquals('user2', $user2->getUID()); } @@ -336,7 +336,7 @@ class GroupTest extends \Test\TestCase { $users = $group->searchUsers('2'); $this->assertEquals(1, count($users)); - $user2 = $users['user2']; + $user2 = reset($users); $this->assertEquals('user2', $user2->getUID()); } @@ -355,7 +355,7 @@ class GroupTest extends \Test\TestCase { $users = $group->searchUsers('user', 1, 1); $this->assertEquals(1, count($users)); - $user2 = $users['user2']; + $user2 = reset($users); $this->assertEquals('user2', $user2->getUID()); } @@ -381,8 +381,8 @@ class GroupTest extends \Test\TestCase { $users = $group->searchUsers('user', 2, 1); $this->assertEquals(2, count($users)); - $user2 = $users['user2']; - $user1 = $users['user1']; + $user2 = reset($users); + $user1 = next($users); $this->assertEquals('user2', $user2->getUID()); $this->assertEquals('user1', $user1->getUID()); } diff --git a/tests/lib/Group/ManagerTest.php b/tests/lib/Group/ManagerTest.php index 186f9d619a2..710d3888d55 100644 --- a/tests/lib/Group/ManagerTest.php +++ b/tests/lib/Group/ManagerTest.php @@ -27,6 +27,7 @@ use OC\Group\Database; use OC\User\User; use OC\User\Manager; use OCP\GroupInterface; +use OCP\Group\Backend\ISearchableGroupBackend; use OCP\ICacheFactory; use OCP\IUser; use PHPUnit\Framework\MockObject\MockObject; @@ -34,6 +35,9 @@ use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; +interface ISearchableGroupInterface extends ISearchableGroupBackend, GroupInterface { +} + class ManagerTest extends TestCase { /** @var Manager|MockObject */ protected $userManager; @@ -79,7 +83,7 @@ class ManagerTest extends TestCase { } // need to declare it this way due to optional methods // thanks to the implementsActions logic - $backend = $this->getMockBuilder(GroupInterface::class) + $backend = $this->getMockBuilder(ISearchableGroupInterface::class) ->disableOriginalConstructor() ->setMethods([ 'getGroupDetails', |