]> source.dussan.org Git - nextcloud-server.git/commitdiff
add test to make sure filepaths that are passed to filesystems hooks are normalized
authorRobin Appelman <icewind@owncloud.com>
Mon, 1 Oct 2012 12:00:14 +0000 (14:00 +0200)
committerRobin Appelman <icewind@owncloud.com>
Mon, 1 Oct 2012 12:00:14 +0000 (14:00 +0200)
tests/lib/filesystem.php

index bc3b4d06aa18018e35a2da709228ed4d2a9f4ac7..050dfa5280d565f4b52514a8611d4539693a5afa 100644 (file)
@@ -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
+       }
 }