summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests/cache.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-03-28 15:26:15 +0100
committerRobin Appelman <icewind@owncloud.com>2014-03-28 15:26:15 +0100
commitfe78d963d9a7cbae6aabd8e1a275c6de783440ba (patch)
tree3019fe45948310ced422be8d2cf31d372f4af471 /apps/files_sharing/tests/cache.php
parentf331d5f9d4a4609370bf6a5593e0720ba7c77c04 (diff)
downloadnextcloud-server-fe78d963d9a7cbae6aabd8e1a275c6de783440ba.tar.gz
nextcloud-server-fe78d963d9a7cbae6aabd8e1a275c6de783440ba.zip
Implement getPath for shared files
Diffstat (limited to 'apps/files_sharing/tests/cache.php')
-rw-r--r--apps/files_sharing/tests/cache.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/apps/files_sharing/tests/cache.php b/apps/files_sharing/tests/cache.php
index a75e1860527..47969833ab5 100644
--- a/apps/files_sharing/tests/cache.php
+++ b/apps/files_sharing/tests/cache.php
@@ -246,4 +246,43 @@ class Test_Files_Sharing_Cache extends Test_Files_Sharing_Base {
}
}
+ public function testGetPathByIdDirectShare() {
+ 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\PERMISSION_ALL);
+ \OC_Util::tearDownFS();
+
+ self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
+ $this->assertTrue(\OC\Files\Filesystem::file_exists('/Shared/test.txt'));
+ list($sharedStorage) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/Shared/test.txt');
+ /**
+ * @var \OC\Files\Storage\Shared $sharedStorage
+ */
+
+ $sharedCache = $sharedStorage->getCache();
+ $this->assertEquals('test.txt', $sharedCache->getPathById($info->getId()));
+ }
+
+ public function testGetPathByIdShareSubFolder() {
+ self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
+ \OC\Files\Filesystem::mkdir('foo');
+ \OC\Files\Filesystem::mkdir('foo/bar');
+ \OC\Files\Filesystem::touch('foo/bar/test.txt', 'bar');
+ $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\PERMISSION_ALL);
+ \OC_Util::tearDownFS();
+
+ self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
+ $this->assertTrue(\OC\Files\Filesystem::file_exists('/Shared/foo'));
+ list($sharedStorage) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/Shared/foo');
+ /**
+ * @var \OC\Files\Storage\Shared $sharedStorage
+ */
+
+ $sharedCache = $sharedStorage->getCache();
+ $this->assertEquals('foo', $sharedCache->getPathById($folderInfo->getId()));
+ $this->assertEquals('foo/bar/test.txt', $sharedCache->getPathById($fileInfo->getId()));
+ }
}