aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-10-01 14:00:14 +0200
committerRobin Appelman <icewind@owncloud.com>2012-10-01 14:00:14 +0200
commitf77dc9b30fd1720ed3cc84c52fe0ba1b1c186e8c (patch)
tree753e5834ffc7901e3652fba6d86735fe79c7dc8c /tests
parenta61c8203697074d7dbbdbc579381dc57372e71bb (diff)
downloadnextcloud-server-f77dc9b30fd1720ed3cc84c52fe0ba1b1c186e8c.tar.gz
nextcloud-server-f77dc9b30fd1720ed3cc84c52fe0ba1b1c186e8c.zip
add test to make sure filepaths that are passed to filesystems hooks are normalized
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/filesystem.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/lib/filesystem.php b/tests/lib/filesystem.php
index bc3b4d06aa1..050dfa5280d 100644
--- a/tests/lib/filesystem.php
+++ b/tests/lib/filesystem.php
@@ -71,4 +71,27 @@ class Test_Filesystem extends UnitTestCase {
$this->assertEqual("/foo/bar\xC3\xBC", OC_Filesystem::normalizePath("/foo/baru\xCC\x88"));
}
}
+
+ public function testHooks() {
+ $user = OC_User::getUser();
+ OC_Hook::clear('OC_Filesystem');
+ OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHook');
+
+ OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/');
+
+ OC_Filesystem::init('');
+ OC_Filesystem::file_put_contents('/foo', 'foo');
+ OC_Filesystem::mkdir('/bar');
+ OC_Filesystem::file_put_contents('/bar//foo', 'foo');
+
+ $tmpFile = OC_Helper::tmpFile();
+ file_put_contents($tmpFile, 'foo');
+ $fh = fopen($tmpFile, 'r');
+ OC_Filesystem::file_put_contents('/bar//foo', $fh);
+ }
+
+ public function dummyHook($arguments) {
+ $path = $arguments['path'];
+ $this->assertEqual($path, OC_Filesystem::normalizePath($path)); //the path passed to the hook should already be normalized
+ }
}