diff options
Diffstat (limited to 'apps/files_sharing/tests/permissions.php')
-rw-r--r-- | apps/files_sharing/tests/permissions.php | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/apps/files_sharing/tests/permissions.php b/apps/files_sharing/tests/permissions.php index 43a57266851..c1568ceab0a 100644 --- a/apps/files_sharing/tests/permissions.php +++ b/apps/files_sharing/tests/permissions.php @@ -33,39 +33,25 @@ use OC\Files\View; */ class Test_Files_Sharing_Permissions extends OCA\Files_sharing\Tests\TestCase { - /** - * @var Storage - */ + /** @var Storage */ private $sharedStorageRestrictedShare; - /** - * @var Storage - */ + /** @var Storage */ private $sharedCacheRestrictedShare; - /** - * @var View - */ + /** @var View */ private $secondView; - /** - * @var Storage - */ + /** @var Storage */ private $ownerStorage; - /** - * @var Storage - */ + /** @var Storage */ private $sharedStorage; - /** - * @var Cache - */ + /** @var Cache */ private $sharedCache; - /** - * @var Cache - */ + /** @var Cache */ private $ownerCache; protected function setUp() { @@ -88,12 +74,25 @@ class Test_Files_Sharing_Permissions extends OCA\Files_sharing\Tests\TestCase { $this->ownerStorage->getScanner()->scan(''); // share "shareddir" with user2 - $fileinfo = $this->view->getFileInfo('container/shareddir'); - \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, - self::TEST_FILES_SHARING_API_USER2, 31); - $fileinfo2 = $this->view->getFileInfo('container/shareddirrestricted'); - \OCP\Share::shareItem('folder', $fileinfo2['fileid'], \OCP\Share::SHARE_TYPE_USER, - self::TEST_FILES_SHARING_API_USER2, 7); + $rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1); + + $node = $rootFolder->get('container/shareddir'); + $share = $this->shareManager->newShare(); + $share->setNode($node) + ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) + ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) + ->setPermissions(\OCP\Constants::PERMISSION_ALL); + $this->shareManager->createShare($share); + + $node = $rootFolder->get('container/shareddirrestricted'); + $share = $this->shareManager->newShare(); + $share->setNode($node) + ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) + ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) + ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE); + $this->shareManager->createShare($share); // login as user2 self::loginHelper(self::TEST_FILES_SHARING_API_USER2); @@ -113,12 +112,10 @@ class Test_Files_Sharing_Permissions extends OCA\Files_sharing\Tests\TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); - $fileinfo = $this->view->getFileInfo('container/shareddir'); - \OCP\Share::unshare('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, - self::TEST_FILES_SHARING_API_USER2); - $fileinfo2 = $this->view->getFileInfo('container/shareddirrestricted'); - \OCP\Share::unshare('folder', $fileinfo2['fileid'], \OCP\Share::SHARE_TYPE_USER, - self::TEST_FILES_SHARING_API_USER2); + $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER); + foreach ($shares as $share) { + $this->shareManager->deleteShare($share); + } $this->view->deleteAll('container'); |