summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-06-26 16:32:05 +0200
committerVincent Petry <pvince81@owncloud.com>2015-06-26 16:32:28 +0200
commit56d9df34cb4bed8267453bcf894f7ead775a5827 (patch)
tree4a70c50a171724ff8db712d8259773ceff11048e
parent5e1865530b7c11884a5a889d40aa30768d6388e3 (diff)
downloadnextcloud-server-56d9df34cb4bed8267453bcf894f7ead775a5827.tar.gz
nextcloud-server-56d9df34cb4bed8267453bcf894f7ead775a5827.zip
Unit test for etag update on custom share folder
-rw-r--r--apps/files_sharing/tests/updater.php44
1 files changed, 36 insertions, 8 deletions
diff --git a/apps/files_sharing/tests/updater.php b/apps/files_sharing/tests/updater.php
index 294388bfe26..cf02504ea96 100644
--- a/apps/files_sharing/tests/updater.php
+++ b/apps/files_sharing/tests/updater.php
@@ -117,14 +117,34 @@ class Test_Files_Sharing_Updater extends OCA\Files_Sharing\Tests\TestCase {
\OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
}
+ public function shareFolderProvider() {
+ return [
+ ['/'],
+ ['/my_shares'],
+ ];
+ }
+
/**
* if a file gets shared the etag for the recipients root should change
+ *
+ * @dataProvider shareFolderProvider
+ *
+ * @param string $shareFolder share folder to use
*/
- function testShareFile() {
+ public function testShareFile($shareFolder) {
+ $config = \OC::$server->getConfig();
+ $oldShareFolder = $config->getSystemValue('share_folder');
+ $config->setSystemValue('share_folder', $shareFolder);
+
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $beforeShare = \OC\Files\Filesystem::getFileInfo('');
- $etagBeforeShare = $beforeShare->getEtag();
+ $beforeShareRoot = \OC\Files\Filesystem::getFileInfo('');
+ $etagBeforeShareRoot = $beforeShareRoot->getEtag();
+
+ \OC\Files\Filesystem::mkdir($shareFolder);
+
+ $beforeShareDir = \OC\Files\Filesystem::getFileInfo($shareFolder);
+ $etagBeforeShareDir = $beforeShareDir->getEtag();
$this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
$fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder);
@@ -133,17 +153,25 @@ class Test_Files_Sharing_Updater extends OCA\Files_Sharing\Tests\TestCase {
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $afterShare = \OC\Files\Filesystem::getFileInfo('');
- $etagAfterShare = $afterShare->getEtag();
+ $afterShareRoot = \OC\Files\Filesystem::getFileInfo('');
+ $etagAfterShareRoot = $afterShareRoot->getEtag();
+
+ $afterShareDir = \OC\Files\Filesystem::getFileInfo($shareFolder);
+ $etagAfterShareDir = $afterShareDir->getEtag();
- $this->assertTrue(is_string($etagBeforeShare));
- $this->assertTrue(is_string($etagAfterShare));
- $this->assertTrue($etagBeforeShare !== $etagAfterShare);
+ $this->assertTrue(is_string($etagBeforeShareRoot));
+ $this->assertTrue(is_string($etagBeforeShareDir));
+ $this->assertTrue(is_string($etagAfterShareRoot));
+ $this->assertTrue(is_string($etagAfterShareDir));
+ $this->assertTrue($etagBeforeShareRoot !== $etagAfterShareRoot);
+ $this->assertTrue($etagBeforeShareDir !== $etagAfterShareDir);
// cleanup
$this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
$result = \OCP\Share::unshare('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$this->assertTrue($result);
+
+ $config->setSystemValue('share_folder', $oldShareFolder);
}
/**