diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2014-06-23 18:33:13 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2014-06-23 18:33:13 +0200 |
commit | 5dab762006e25407d7df2bceb00b4960a01d317d (patch) | |
tree | 33a1c2fe0054f134aa54e7ba6f6fec8c3cae85e1 /tests | |
parent | 01a012980afa1bed5b2db1006a9d6443f19e3d5f (diff) | |
download | nextcloud-server-5dab762006e25407d7df2bceb00b4960a01d317d.tar.gz nextcloud-server-5dab762006e25407d7df2bceb00b4960a01d317d.zip |
add tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/group/backend.php | 39 | ||||
-rw-r--r-- | tests/lib/user/backend.php | 17 | ||||
-rw-r--r-- | tests/lib/user/database.php | 3 |
3 files changed, 58 insertions, 1 deletions
diff --git a/tests/lib/group/backend.php b/tests/lib/group/backend.php index 2c563ae9ac9..b6e3fa2b003 100644 --- a/tests/lib/group/backend.php +++ b/tests/lib/group/backend.php @@ -88,7 +88,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 +102,41 @@ 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 = 'foobarbaz'; + $name2 = 'bazbarfoo'; + $name3 = 'notme'; + + $this->backend->createGroup($name1); + $this->backend->createGroup($name2); + $this->backend->createGroup($name3); + + $result = $this->backend->getGroups('bar'); + $this->assertSame(2, count($result)); + + $result = $this->backend->getDisplayNames('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($group, $name1); + $this->backend->addToGroup($group, $name2); + $this->backend->addToGroup($group, $name3); + + $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/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); } |