summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-08-29 15:25:38 +0200
committerRobin Appelman <icewind@owncloud.com>2013-08-29 15:25:38 +0200
commitbf9045f585517fdb04e205783634f39852964a07 (patch)
tree25da0a9ac06ef13d20aadd6eab6ceeaf744244e6
parentd43b4c52ae0169d80e10532db4ce2103f211cd56 (diff)
downloadnextcloud-server-bf9045f585517fdb04e205783634f39852964a07.tar.gz
nextcloud-server-bf9045f585517fdb04e205783634f39852964a07.zip
test case for hooks send from a non-default view
-rw-r--r--tests/lib/files/view.php31
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 3bac9e770aa..0de436f570a 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -25,7 +25,7 @@ class View extends \PHPUnit_Framework_TestCase {
//login
\OC_User::createUser('test', 'test');
- $this->user=\OC_User::getUser();
+ $this->user = \OC_User::getUser();
\OC_User::setUserId('test');
\OC\Files\Filesystem::clearMounts();
@@ -326,6 +326,35 @@ class View extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
+ */
+ 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
*/