diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-11-04 13:07:16 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-11-04 20:55:47 +0100 |
commit | 04ece69a33110421ba3011423b1051eb9994b9f2 (patch) | |
tree | c1811bc711e898474e4a3498833dcf6d06c90f4c /apps | |
parent | 27304e5694fdec3eebf0700f2a82d9d80e928558 (diff) | |
download | nextcloud-server-04ece69a33110421ba3011423b1051eb9994b9f2.tar.gz nextcloud-server-04ece69a33110421ba3011423b1051eb9994b9f2.zip |
Cleanup OC_Group usage a bit
This is deprecated internal stuff. Should not be used anymore.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/tests/ShareTest.php | 12 | ||||
-rw-r--r-- | apps/files_sharing/tests/SharedMountTest.php | 62 |
2 files changed, 49 insertions, 25 deletions
diff --git a/apps/files_sharing/tests/ShareTest.php b/apps/files_sharing/tests/ShareTest.php index c1e61152e63..9b60255ed97 100644 --- a/apps/files_sharing/tests/ShareTest.php +++ b/apps/files_sharing/tests/ShareTest.php @@ -71,10 +71,14 @@ class ShareTest extends TestCase { } public function testUnshareFromSelf() { - - \OC_Group::createGroup('testGroup'); - \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup'); - \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup'); + $groupManager = \OC::$server->getGroupManager(); + $userManager = \OC::$server->getUserManager(); + + $testGroup = $groupManager->createGroup('testGroup'); + $user1 = $userManager->get(self::TEST_FILES_SHARING_API_USER2); + $user2 = $userManager->get(self::TEST_FILES_SHARING_API_USER3); + $testGroup->addUser($user1); + $testGroup->addUser($user2); $share1 = $this->share( \OCP\Share::SHARE_TYPE_USER, diff --git a/apps/files_sharing/tests/SharedMountTest.php b/apps/files_sharing/tests/SharedMountTest.php index 5f769852dc8..72cc891e368 100644 --- a/apps/files_sharing/tests/SharedMountTest.php +++ b/apps/files_sharing/tests/SharedMountTest.php @@ -27,6 +27,8 @@ */ namespace OCA\Files_Sharing\Tests; +use OCP\IGroupManager; +use OCP\IUserManager; /** * Class SharedMountTest @@ -35,6 +37,12 @@ namespace OCA\Files_Sharing\Tests; */ class SharedMountTest extends TestCase { + /** @var IGroupManager */ + private $groupManager; + + /** @var IUserManager */ + private $userManager; + protected function setUp() { parent::setUp(); @@ -48,6 +56,9 @@ class SharedMountTest extends TestCase { // save file with content $this->view->file_put_contents($this->filename, "root file"); $this->view->file_put_contents($this->folder . $this->filename, "file in subfolder"); + + $this->groupManager = \OC::$server->getGroupManager(); + $this->userManager = \OC::$server->getUserManager(); } protected function tearDown() { @@ -172,10 +183,13 @@ class SharedMountTest extends TestCase { * for the other users */ public function testMoveGroupShare () { - \OC_Group::createGroup('testGroup'); - \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER1, 'testGroup'); - \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup'); - \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup'); + $testGroup = $this->groupManager->createGroup('testGroup'); + $user1 = $this->userManager->get(self::TEST_FILES_SHARING_API_USER1); + $user2 = $this->userManager->get(self::TEST_FILES_SHARING_API_USER2); + $user3 = $this->userManager->get(self::TEST_FILES_SHARING_API_USER3); + $testGroup->addUser($user1); + $testGroup->addUser($user2); + $testGroup->addUser($user3); $fileinfo = $this->view->getFileInfo($this->filename); $share = $this->share( @@ -206,9 +220,9 @@ class SharedMountTest extends TestCase { //cleanup self::loginHelper(self::TEST_FILES_SHARING_API_USER1); $this->shareManager->deleteShare($share); - \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER1, 'testGroup'); - \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup'); - \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup'); + $testGroup->removeUser($user1); + $testGroup->removeUser($user2); + $testGroup->removeUser($user3); } /** @@ -317,10 +331,13 @@ class SharedMountTest extends TestCase { $path = $this->folder; } - \OC_Group::createGroup('testGroup'); - \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER1, 'testGroup'); - \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup'); - \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup'); + $testGroup = $this->groupManager->createGroup('testGroup'); + $user1 = $this->userManager->get(self::TEST_FILES_SHARING_API_USER1); + $user2 = $this->userManager->get(self::TEST_FILES_SHARING_API_USER2); + $user3 = $this->userManager->get(self::TEST_FILES_SHARING_API_USER3); + $testGroup->addUser($user1); + $testGroup->addUser($user2); + $testGroup->addUser($user3); // Share item with group $share = $this->share( @@ -362,9 +379,9 @@ class SharedMountTest extends TestCase { //cleanup self::loginHelper(self::TEST_FILES_SHARING_API_USER1); $this->shareManager->deleteShare($share); - \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER1, 'testGroup'); - \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup'); - \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup'); + $testGroup->removeUser($user1); + $testGroup->removeUser($user2); + $testGroup->removeUser($user3); } /** @@ -372,10 +389,13 @@ class SharedMountTest extends TestCase { * removed shares by a member of that group */ function testPermissionUpgradeOnUserDeletedGroupShare() { - \OC_Group::createGroup('testGroup'); - \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER1, 'testGroup'); - \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup'); - \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup'); + $testGroup = $this->groupManager->createGroup('testGroup'); + $user1 = $this->userManager->get(self::TEST_FILES_SHARING_API_USER1); + $user2 = $this->userManager->get(self::TEST_FILES_SHARING_API_USER2); + $user3 = $this->userManager->get(self::TEST_FILES_SHARING_API_USER3); + $testGroup->addUser($user1); + $testGroup->addUser($user2); + $testGroup->addUser($user3); $connection = \OC::$server->getDatabaseConnection(); @@ -419,9 +439,9 @@ class SharedMountTest extends TestCase { //cleanup self::loginHelper(self::TEST_FILES_SHARING_API_USER1); - \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER1, 'testGroup'); - \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup'); - \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup'); + $testGroup->removeUser($user1); + $testGroup->removeUser($user2); + $testGroup->removeUser($user3); } } |