summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-03-09 16:20:18 +0100
committerRobin Appelman <icewind@owncloud.com>2015-04-27 14:07:15 +0200
commit30ad56813a16908e3862c353256f2a6d0f05fe3a (patch)
tree284153f54d9ad64f377602c2ce6b2dc83f3cc445 /apps/files_sharing/tests
parent518d5aadf51318886481696e4308fcc39684b508 (diff)
downloadnextcloud-server-30ad56813a16908e3862c353256f2a6d0f05fe3a.tar.gz
nextcloud-server-30ad56813a16908e3862c353256f2a6d0f05fe3a.zip
propagate etags for all user of a share
Diffstat (limited to 'apps/files_sharing/tests')
-rw-r--r--apps/files_sharing/tests/propagation.php48
-rw-r--r--apps/files_sharing/tests/testcase.php7
2 files changed, 54 insertions, 1 deletions
diff --git a/apps/files_sharing/tests/propagation.php b/apps/files_sharing/tests/propagation.php
index 1949f7808a4..c42dccce88f 100644
--- a/apps/files_sharing/tests/propagation.php
+++ b/apps/files_sharing/tests/propagation.php
@@ -242,4 +242,52 @@ class Propagation extends TestCase {
$newRootInfo = $view1->getFileInfo('');
$this->assertNotEquals($rootInfo->getEtag(), $newRootInfo->getEtag());
}
+
+ public function testSizePropagationWhenOwnerChangesFile() {
+ /**
+ * @var \OC\Files\View $recipientView
+ * @var \OC\Files\View $ownerView
+ */
+ list($recipientView, $ownerView) = $this->setupViews();
+ $sharedFolderInfo = $ownerView->getFileInfo('/sharedfolder', false);
+ \OCP\Share::shareItem('folder', $sharedFolderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER1, 31);
+ $ownerRootInfo = $ownerView->getFileInfo('', false);
+ $this->loginAsUser(self::TEST_FILES_SHARING_API_USER1);
+ $this->assertTrue($recipientView->file_exists('/sharedfolder/subfolder/foo.txt'));
+ $recipientRootInfo = $recipientView->getFileInfo('', false);
+ // when file changed as owner
+ $this->loginAsUser(self::TEST_FILES_SHARING_API_USER2);
+ $ownerView->file_put_contents('/sharedfolder/subfolder/foo.txt', 'foobar');
+ // size of recipient's root stays the same
+ $this->loginAsUser(self::TEST_FILES_SHARING_API_USER1);
+ $newRecipientRootInfo = $recipientView->getFileInfo('', false);
+ $this->assertEquals($recipientRootInfo->getSize(), $newRecipientRootInfo->getSize());
+ // size of owner's root increases
+ $this->loginAsUser(self::TEST_FILES_SHARING_API_USER2);
+ $newOwnerRootInfo = $ownerView->getFileInfo('', false);
+ $this->assertEquals($ownerRootInfo->getSize() + 3, $newOwnerRootInfo->getSize());
+ }
+
+ public function testSizePropagationWhenRecipientChangesFile() {
+ /**
+ * @var \OC\Files\View $recipientView
+ * @var \OC\Files\View $ownerView
+ */
+ list($recipientView, $ownerView) = $this->setupViews();
+ $sharedFolderInfo = $ownerView->getFileInfo('/sharedfolder', false);
+ \OCP\Share::shareItem('folder', $sharedFolderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER1, 31);
+ $ownerRootInfo = $ownerView->getFileInfo('', false);
+ $this->loginAsUser(self::TEST_FILES_SHARING_API_USER1);
+ $this->assertTrue($recipientView->file_exists('/sharedfolder/subfolder/foo.txt'));
+ $recipientRootInfo = $recipientView->getFileInfo('', false);
+ // when file changed as recipient
+ $recipientView->file_put_contents('/sharedfolder/subfolder/foo.txt', 'foobar');
+ // size of recipient's root stays the same
+ $newRecipientRootInfo = $recipientView->getFileInfo('', false);
+ $this->assertEquals($recipientRootInfo->getSize(), $newRecipientRootInfo->getSize());
+ // size of owner's root increases
+ $this->loginAsUser(self::TEST_FILES_SHARING_API_USER2);
+ $newOwnerRootInfo = $ownerView->getFileInfo('', false);
+ $this->assertEquals($ownerRootInfo->getSize() + 3, $newOwnerRootInfo->getSize());
+ }
}
diff --git a/apps/files_sharing/tests/testcase.php b/apps/files_sharing/tests/testcase.php
index b9f8658a69e..5cae54fef6c 100644
--- a/apps/files_sharing/tests/testcase.php
+++ b/apps/files_sharing/tests/testcase.php
@@ -31,6 +31,7 @@ namespace OCA\Files_Sharing\Tests;
use OC\Files\Filesystem;
use OCA\Files\Share;
+use OCA\Files_Sharing\Appinfo\Application;
/**
* Class Test_Files_Sharing_Base
@@ -57,6 +58,10 @@ abstract class TestCase extends \Test\TestCase {
public static function setUpBeforeClass() {
parent::setUpBeforeClass();
+ $application = new Application();
+ $application->registerMountProviders();
+ $application->setupPropagation();
+
// reset backend
\OC_User::clearBackends();
\OC_Group::clearBackends();
@@ -64,7 +69,6 @@ abstract class TestCase extends \Test\TestCase {
// clear share hooks
\OC_Hook::clear('OCP\\Share');
\OC::registerShareHooks();
- \OCP\Util::connectHook('OC_Filesystem', 'setup', '\OC\Files\Storage\Shared', 'setup');
// create users
$backend = new \OC_User_Dummy();
@@ -147,6 +151,7 @@ abstract class TestCase extends \Test\TestCase {
\OC::$server->getUserSession()->setUser(null);
\OC\Files\Filesystem::tearDown();
\OC::$server->getUserSession()->login($user, $password);
+
\OC_Util::setupFS($user);
}