summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2012-11-28 18:30:47 +0100
committerBernhard Posselt <nukeawhale@gmail.com>2012-11-28 18:30:47 +0100
commit37e524dc6d12c9a7d8b8f845b5a2a04506783cf1 (patch)
treeea24a2db798238f1261cc8586f487be435d7eeab /tests
parenteaa625c9bc426dcba0427457777a79a3944628a5 (diff)
downloadnextcloud-server-37e524dc6d12c9a7d8b8f845b5a2a04506783cf1.tar.gz
nextcloud-server-37e524dc6d12c9a7d8b8f845b5a2a04506783cf1.zip
added more unittests for the group file
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/group.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/lib/group.php b/tests/lib/group.php
index 7b9ca3414b0..28264b0f168 100644
--- a/tests/lib/group.php
+++ b/tests/lib/group.php
@@ -3,7 +3,9 @@
* ownCloud
*
* @author Robin Appelman
+* @author Bernhard Posselt
* @copyright 2012 Robin Appelman icewind@owncloud.com
+* @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
@@ -62,6 +64,72 @@ class Test_Group extends UnitTestCase {
$this->assertFalse(OC_Group::inGroup($user1, $group1));
}
+
+ public function testNoEmptyGIDs(){
+ OC_Group::useBackend(new OC_Group_Dummy());
+ $emptyGroup = null;
+
+ $this->assertEqual(false, OC_Group::createGroup($emptyGroup));
+ }
+
+
+ public function testNoGroupsTwice(){
+ OC_Group::useBackend(new OC_Group_Dummy());
+ $group = uniqid();
+ OC_Group::createGroup($group);
+
+ $groupCopy = $group;
+
+ $this->assertEqual(false, OC_Group::createGroup($groupCopy));
+ $this->assertEqual(array($group), OC_Group::getGroups());
+ }
+
+
+ public function testDontDeleteAdminGroup(){
+ OC_Group::useBackend(new OC_Group_Dummy());
+ $adminGroup = 'admin';
+ OC_Group::createGroup($adminGroup);
+
+ $this->assertEqual(false, OC_Group::deleteGroup($adminGroup));
+ $this->assertEqual(array($adminGroup), OC_Group::getGroups());
+ }
+
+
+ public function testDontAddUserToNonexistentGroup(){
+ OC_Group::useBackend(new OC_Group_Dummy());
+ $groupNonExistent = 'notExistent';
+ $user = uniqid();
+
+ $this->assertEqual(false, OC_Group::addToGroup($user, $groupNonExistent));
+ $this->assertEqual(array(), OC_Group::getGroups());
+ }
+
+
+ public function testUsersInGroup(){
+ OC_Group::useBackend(new OC_Group_Dummy());
+ $group1 = uniqid();
+ $group2 = uniqid();
+ $group3 = uniqid();
+ $user1 = uniqid();
+ $user2 = uniqid();
+ $user3 = uniqid();
+ OC_Group::createGroup($group1);
+ OC_Group::createGroup($group2);
+ OC_Group::createGroup($group3);
+
+ OC_Group::addToGroup($user1, $group1);
+ OC_Group::addToGroup($user2, $group1);
+ OC_Group::addToGroup($user3, $group1);
+ OC_Group::addToGroup($user3, $group2);
+
+ $this->assertEqual(array($user1, $user2, $user3),
+ OC_Group::usersInGroups(array($group1, $group2, $group3)));
+
+ // FIXME: needs more parameter variation
+ }
+
+
+
function testMultiBackend() {
$backend1=new OC_Group_Dummy();
$backend2=new OC_Group_Dummy();