]> source.dussan.org Git - nextcloud-server.git/commitdiff
Update tests to test for create and update aswell
authorJoas Schilling <nickvergessen@gmx.de>
Mon, 28 Apr 2014 08:49:35 +0000 (10:49 +0200)
committerJoas Schilling <nickvergessen@gmx.de>
Tue, 29 Apr 2014 08:34:28 +0000 (10:34 +0200)
tests/lib/files/view.php

index c85f1128dbed36165f7b16acbc6648166188d729..682f3bb52af1730febe24bc3ec006314c84a7e6e 100644 (file)
@@ -393,14 +393,15 @@ class View extends \PHPUnit_Framework_TestCase {
                $rootView->file_put_contents('/foo.txt', 'asd');
                $this->assertNull($this->hookPath);
 
+               $this->hookWritePath = $this->hookUpdatePath = $this->hookCreatePath = null;
+
                $subView->file_put_contents('/foo.txt', 'asd');
-               $this->assertNotNull($this->hookPath);
                $this->assertEquals('/substorage/foo.txt', $this->hookPath);
        }
 
        private $hookPath;
 
-       function dummyHook($params) {
+       public function dummyHook($params) {
                $this->hookPath = $params['path'];
        }
 
@@ -442,12 +443,6 @@ class View extends \PHPUnit_Framework_TestCase {
                return $storage;
        }
 
-       private $createHookPath;
-
-       function dummyCreateHook($params) {
-               $this->createHookPath = $params['path'];
-       }
-
        /**
         * @medium
         */
@@ -466,23 +461,50 @@ class View extends \PHPUnit_Framework_TestCase {
                $this->assertNull($this->hookPath);
        }
 
+       private $hookWritePath;
+       private $hookCreatePath;
+       private $hookUpdatePath;
+
+       public function dummyHookWrite($params) {
+               $this->hookWritePath = $params['path'];
+       }
+
+       public function dummyHookUpdate($params) {
+               $this->hookUpdatePath = $params['path'];
+       }
+
+       public function dummyHookCreate($params) {
+               $this->hookCreatePath = $params['path'];
+       }
+
        public function testEditNoCreateHook() {
                $storage1 = $this->getTestStorage();
                $storage2 = $this->getTestStorage();
                $defaultRoot = \OC\Files\Filesystem::getRoot();
                \OC\Files\Filesystem::mount($storage1, array(), '/');
                \OC\Files\Filesystem::mount($storage2, array(), $defaultRoot);
-               \OC_Hook::connect('OC_Filesystem', 'post_create', $this, 'dummyCreateHook');
+               \OC_Hook::connect('OC_Filesystem', 'post_create', $this, 'dummyHookCreate');
+               \OC_Hook::connect('OC_Filesystem', 'post_update', $this, 'dummyHookUpdate');
+               \OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHookWrite');
 
                $view = new \OC\Files\View($defaultRoot);
-               $this->hookPath = null;
+               $this->hookWritePath = $this->hookUpdatePath = $this->hookCreatePath = null;
 
                $view->file_put_contents('/asd.txt', 'foo');
-               $this->assertEquals('/asd.txt', $this->createHookPath);
-               $this->createHookPath = null;
+               $this->assertEquals('/asd.txt', $this->hookCreatePath);
+               $this->assertNull($this->hookUpdatePath);
+               $this->assertEquals('/asd.txt', $this->hookWritePath);
+
+               $this->hookWritePath = $this->hookUpdatePath = $this->hookCreatePath = null;
 
                $view->file_put_contents('/asd.txt', 'foo');
-               $this->assertNull($this->createHookPath);
+               $this->assertNull($this->hookCreatePath);
+               $this->assertEquals('/asd.txt', $this->hookUpdatePath);
+               $this->assertEquals('/asd.txt', $this->hookWritePath);
+
+               \OC_Hook::clear('OC_Filesystem', 'post_create');
+               \OC_Hook::clear('OC_Filesystem', 'post_update');
+               \OC_Hook::clear('OC_Filesystem', 'post_write');
        }
 
        /**