mirror of
https://github.com/nextcloud/server.git
synced 2026-04-22 14:50:17 -04:00
add tests
This commit is contained in:
parent
01a012980a
commit
5dab762006
3 changed files with 58 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue