diff options
author | blizzz <blizzz@owncloud.com> | 2014-07-01 14:37:09 +0200 |
---|---|---|
committer | blizzz <blizzz@owncloud.com> | 2014-07-01 14:37:09 +0200 |
commit | 616f9b1e03b7939605ec233f7af5cc78b0be9fde (patch) | |
tree | 70db45859bf3662302a012323bb0e1bfac2344a6 /tests/lib | |
parent | 16ce23d19df352cd2653387bf00a0e210016d2f2 (diff) | |
parent | 16275eca845f7bb7c4872f1120f76177f593a693 (diff) | |
download | nextcloud-server-616f9b1e03b7939605ec233f7af5cc78b0be9fde.tar.gz nextcloud-server-616f9b1e03b7939605ec233f7af5cc78b0be9fde.zip |
Merge pull request #9156 from owncloud/solve-8959
search term for users and groups may occur anywhere in the name or displ...
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/group/backend.php | 44 | ||||
-rw-r--r-- | tests/lib/group/database.php | 6 | ||||
-rw-r--r-- | tests/lib/user/backend.php | 17 | ||||
-rw-r--r-- | tests/lib/user/database.php | 3 |
4 files changed, 65 insertions, 5 deletions
diff --git a/tests/lib/group/backend.php b/tests/lib/group/backend.php index 2c563ae9ac9..95a5cf5f49c 100644 --- a/tests/lib/group/backend.php +++ b/tests/lib/group/backend.php @@ -31,8 +31,12 @@ abstract class Test_Group_Backend extends PHPUnit_Framework_TestCase { * test cases can override this in order to clean up created groups * @return string */ - public function getGroupName() { - return uniqid('test_'); + public function getGroupName($name = null) { + if(is_null($name)) { + return uniqid('test_'); + } else { + return $name; + } } /** @@ -88,7 +92,7 @@ abstract class Test_Group_Backend extends PHPUnit_Framework_TestCase { $this->assertFalse($this->backend->inGroup($user2, $group1)); $this->assertFalse($this->backend->inGroup($user1, $group2)); $this->assertFalse($this->backend->inGroup($user2, $group2)); - + $this->assertFalse($this->backend->addToGroup($user1, $group1)); $this->assertEquals(array($user1), $this->backend->usersInGroup($group1)); @@ -102,4 +106,38 @@ abstract class Test_Group_Backend extends PHPUnit_Framework_TestCase { $this->assertEquals(array(), $this->backend->usersInGroup($group1)); $this->assertFalse($this->backend->inGroup($user1, $group1)); } + + public function testSearchGroups() { + $name1 = $this->getGroupName('foobarbaz'); + $name2 = $this->getGroupName('bazbarfoo'); + $name3 = $this->getGroupName('notme'); + + $this->backend->createGroup($name1); + $this->backend->createGroup($name2); + $this->backend->createGroup($name3); + + $result = $this->backend->getGroups('bar'); + $this->assertSame(2, count($result)); + } + + public function testSearchUsers() { + $group = $this->getGroupName(); + $this->backend->createGroup($group); + + $name1 = 'foobarbaz'; + $name2 = 'bazbarfoo'; + $name3 = 'notme'; + + $this->backend->addToGroup($name1, $group); + $this->backend->addToGroup($name2, $group); + $this->backend->addToGroup($name3, $group); + + $result = $this->backend->usersInGroup($group, 'bar'); + $this->assertSame(2, count($result)); + + $result = $this->backend->countUsersInGroup($group, 'bar'); + $this->assertSame(2, $result); + } + + } diff --git a/tests/lib/group/database.php b/tests/lib/group/database.php index 3e05c656061..9b39ac00452 100644 --- a/tests/lib/group/database.php +++ b/tests/lib/group/database.php @@ -28,8 +28,10 @@ class Test_Group_Database extends Test_Group_Backend { * test cases can override this in order to clean up created groups * @return string */ - public function getGroupName() { - $name=uniqid('test_'); + public function getGroupName($name = null) { + if(is_null($name)) { + $name=uniqid('test_'); + } $this->groups[]=$name; return $name; } diff --git a/tests/lib/user/backend.php b/tests/lib/user/backend.php index 1384c54a921..0d3914c7ca6 100644 --- a/tests/lib/user/backend.php +++ b/tests/lib/user/backend.php @@ -96,4 +96,21 @@ abstract class Test_User_Backend extends PHPUnit_Framework_TestCase { $this->assertSame($name1, $this->backend->checkPassword($name1, 'newpass1')); $this->assertFalse($this->backend->checkPassword($name2, 'newpass1')); } + + public function testSearch() { + $name1 = 'foobarbaz'; + $name2 = 'bazbarfoo'; + $name3 = 'notme'; + + $this->backend->createUser($name1, 'pass1'); + $this->backend->createUser($name2, 'pass2'); + $this->backend->createUser($name3, 'pass3'); + + $result = $this->backend->getUsers('bar'); + $this->assertSame(2, count($result)); + + $result = $this->backend->getDisplayNames('bar'); + $this->assertSame(2, count($result)); + } + } diff --git a/tests/lib/user/database.php b/tests/lib/user/database.php index d7cc39ae387..a8e497720c2 100644 --- a/tests/lib/user/database.php +++ b/tests/lib/user/database.php @@ -32,6 +32,9 @@ class Test_User_Database extends Test_User_Backend { } public function tearDown() { + if(!isset($this->users)) { + return; + } foreach($this->users as $user) { $this->backend->deleteUser($user); } |