summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests/cache.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/tests/cache.php')
-rw-r--r--apps/files_sharing/tests/cache.php101
1 files changed, 59 insertions, 42 deletions
diff --git a/apps/files_sharing/tests/cache.php b/apps/files_sharing/tests/cache.php
index fcc5a343a03..dd727c1c6f2 100644
--- a/apps/files_sharing/tests/cache.php
+++ b/apps/files_sharing/tests/cache.php
@@ -26,27 +26,6 @@
*/
use OCA\Files_sharing\Tests\TestCase;
-/**
- * ownCloud
- *
- * @author Vincent Petry, Bjoern Schiessle
- * @copyright 2014 Vincent Petry <pvince81@owncloud.com>
- * 2014 Bjoern Schiessle <schiessle@owncloud.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- */
/**
* Class Test_Files_Sharing_Cache
@@ -72,9 +51,14 @@ class Test_Files_Sharing_Cache extends TestCase {
/** @var \OC\Files\Storage\Storage */
protected $sharedStorage;
+ /** @var \OCP\Share\IManager */
+ protected $shareManager;
+
protected function setUp() {
parent::setUp();
+ $this->shareManager = \OC::$server->getShareManager();
+
\OC_User::setDisplayName(self::TEST_FILES_SHARING_API_USER1, 'User One');
\OC_User::setDisplayName(self::TEST_FILES_SHARING_API_USER2, 'User Two');
@@ -101,13 +85,25 @@ class Test_Files_Sharing_Cache extends 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);
-
- $fileinfo = $this->view->getFileInfo('container/shared single file.txt');
- \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 31);
+ $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/shared single file.txt');
+ $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 & ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE));
+ $this->shareManager->createShare($share);
// login as user2
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -125,13 +121,10 @@ class Test_Files_Sharing_Cache extends 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);
-
- $fileinfo = $this->view->getFileInfo('container/shared single file.txt');
- \OCP\Share::unshare('file', $fileinfo['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');
@@ -392,9 +385,15 @@ class Test_Files_Sharing_Cache extends TestCase {
function testGetFolderContentsWhenSubSubdirShared() {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $fileinfo = $this->view->getFileInfo('container/shareddir/subdir');
- \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER3, 31);
+ $rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
+ $node = $rootFolder->get('container/shareddir/subdir');
+ $share = $this->shareManager->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedWith(self::TEST_FILES_SHARING_API_USER3)
+ ->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ $share = $this->shareManager->createShare($share);
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
@@ -430,8 +429,7 @@ class Test_Files_Sharing_Cache extends TestCase {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- \OCP\Share::unshare('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER3);
+ $this->shareManager->deleteShare($share);
}
/**
@@ -470,7 +468,17 @@ class Test_Files_Sharing_Cache extends TestCase {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
\OC\Files\Filesystem::file_put_contents('test.txt', 'foo');
$info = \OC\Files\Filesystem::getFileInfo('test.txt');
- \OCP\Share::shareItem('file', $info->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL);
+
+ $rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
+ $node = $rootFolder->get('test.txt');
+ $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_UPDATE | \OCP\Constants::PERMISSION_SHARE);
+ $this->shareManager->createShare($share);
+
\OC_Util::tearDownFS();
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -491,7 +499,16 @@ class Test_Files_Sharing_Cache extends TestCase {
\OC\Files\Filesystem::touch('foo/bar/test.txt');
$folderInfo = \OC\Files\Filesystem::getFileInfo('foo');
$fileInfo = \OC\Files\Filesystem::getFileInfo('foo/bar/test.txt');
- \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL);
+
+ $rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
+ $node = $rootFolder->get('foo');
+ $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);
\OC_Util::tearDownFS();
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);