diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-11-30 00:18:42 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-11-30 00:18:42 +0100 |
commit | d33f697a5f3438f286ba3abe63255b6797a6fc03 (patch) | |
tree | 3bde00fb82540d9a44d0cfe97b41a7c6ecc668d3 /tests | |
parent | a609992a75d1dad15398f55e22ad2244c78650dc (diff) | |
parent | 9b709fa95df5b93b9fb05e33158122003891c154 (diff) | |
download | nextcloud-server-d33f697a5f3438f286ba3abe63255b6797a6fc03.tar.gz nextcloud-server-d33f697a5f3438f286ba3abe63255b6797a6fc03.zip |
merge master into filesystem
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/group.php | 68 | ||||
-rw-r--r-- | tests/lib/share/share.php | 2 |
2 files changed, 70 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(); diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index 3cdae98ca64..92f5d065cf2 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -54,6 +54,8 @@ class Test_Share extends UnitTestCase { OC_Group::addToGroup($this->user2, $this->group2); OC_Group::addToGroup($this->user4, $this->group2); OCP\Share::registerBackend('test', 'Test_Share_Backend'); + OC_Hook::clear('OCP\\Share'); + OC::registerShareHooks(); } public function tearDown() { |