Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2014-07-04 17:15:45 +0400
committerArthur Schiwon <blizzz@owncloud.com>2014-07-04 17:17:20 +0400
commit3bec0dc4f115ca4273cc76ac344f733842c4a43c (patch)
treef0331fb1797c05d5e624146862e7eaf0f6e7f171 /tests
parentb87591a537c5d5cb84b24078e4868293c05989bb (diff)
Backport of #9156
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/group/backend.php41
-rw-r--r--tests/lib/group/database.php6
-rw-r--r--tests/lib/user/backend.php17
-rw-r--r--tests/lib/user/database.php3
4 files changed, 62 insertions, 5 deletions
diff --git a/tests/lib/group/backend.php b/tests/lib/group/backend.php
index d308232a78b..8cf24b9948e 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 array
*/
- 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,35 @@ 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));
+ }
+
+
}
diff --git a/tests/lib/group/database.php b/tests/lib/group/database.php
index 5278c26f4df..53436a76a69 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 array
*/
- 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);
}