summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-06-01 14:08:14 +0200
committerRobin Appelman <icewind@owncloud.com>2015-06-02 14:07:20 +0200
commit4b48dd424f37446dd78f4589d2474fbe47097b1f (patch)
treef24e85ce71fdc0a903056397adcd0843798b8f8d /tests/lib
parent3ebc8f0564395fbb519fc4275e0f6f883df708b7 (diff)
downloadnextcloud-server-4b48dd424f37446dd78f4589d2474fbe47097b1f.tar.gz
nextcloud-server-4b48dd424f37446dd78f4589d2474fbe47097b1f.zip
emit hooks from a view as long as the path is inside the default root
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/files/view.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 06a42d63431..9e4da40a292 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -1107,4 +1107,33 @@ class View extends \Test\TestCase {
$view->lockFile('/foo/bar', ILockingProvider::LOCK_SHARED);
$view->lockFile('/foo/bar', ILockingProvider::LOCK_EXCLUSIVE);
}
+
+ public function hookPathProvider() {
+ return [
+ ['/foo/files', '/foo', true],
+ ['/foo/files/bar', '/foo', true],
+ ['/foo', '/foo', false],
+ ['/foo', '/files/foo', true],
+ ['/foo', 'filesfoo', false]
+ ];
+ }
+
+ /**
+ * @dataProvider hookPathProvider
+ * @param $root
+ * @param $path
+ * @param $shouldEmit
+ */
+ public function testHookPaths($root, $path, $shouldEmit) {
+ $filesystemReflection = new \ReflectionClass('\OC\Files\Filesystem');
+ $defaultRootValue = $filesystemReflection->getProperty('defaultInstance');
+ $defaultRootValue->setAccessible(true);
+ $oldRoot = $defaultRootValue->getValue();
+ $defaultView = new \OC\Files\View('/foo/files');
+ $defaultRootValue->setValue($defaultView);
+ $view = new \OC\Files\View($root);
+ $result = \Test_Helper::invokePrivate($view, 'shouldEmitHooks', [$path]);
+ $defaultRootValue->setValue($oldRoot);
+ $this->assertEquals($shouldEmit, $result);
+ }
}