Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-08-29 17:25:38 +0400
committerRobin Appelman <icewind@owncloud.com>2013-09-10 20:08:59 +0400
commit1a8636eb9c5798595c8e8fa04b96ddd9cbddae35 (patch)
tree7295cfe88fd3ba462eaa620e31da9e4882a7bf92 /tests
parent507a0450db56214534bbaee1012dac4b44ecc51c (diff)
test case for hooks send from a non-default view
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/view.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index a064e44f3ef..1cd07773513 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -14,6 +14,14 @@ class View extends \PHPUnit_Framework_TestCase {
private $storages = array();
public function setUp() {
+ \OC_User::clearBackends();
+ \OC_User::useBackend(new \OC_User_Dummy());
+
+ //login
+ \OC_User::createUser('test', 'test');
+ $this->user = \OC_User::getUser();
+ \OC_User::setUserId('test');
+
\OC\Files\Filesystem::clearMounts();
}
@@ -228,6 +236,32 @@ class View extends \PHPUnit_Framework_TestCase {
$this->assertEquals(3, $cachedData['size']);
}
+ function testViewHooks() {
+ $storage1 = $this->getTestStorage();
+ $storage2 = $this->getTestStorage();
+ $defaultRoot = \OC\Files\Filesystem::getRoot();
+ \OC\Files\Filesystem::mount($storage1, array(), '/');
+ \OC\Files\Filesystem::mount($storage2, array(), $defaultRoot . '/substorage');
+ \OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHook');
+
+ $rootView = new \OC\Files\View('');
+ $subView = new \OC\Files\View($defaultRoot . '/substorage');
+ $this->hookPath = null;
+
+ $rootView->file_put_contents('/foo.txt', 'asd');
+ $this->assertNull($this->hookPath);
+
+ $subView->file_put_contents('/foo.txt', 'asd');
+ $this->assertNotNull($this->hookPath);
+ $this->assertEquals('/substorage/foo.txt', $this->hookPath);
+ }
+
+ private $hookPath;
+
+ function dummyHook($params) {
+ $this->hookPath = $params['path'];
+ }
+
/**
* @param bool $scan
* @return \OC\Files\Storage\Storage