]> source.dussan.org Git - nextcloud-server.git/commitdiff
merge master into hooks-view-same-start
authorRobin Appelman <icewind@owncloud.com>
Thu, 10 Oct 2013 09:34:30 +0000 (11:34 +0200)
committerRobin Appelman <icewind@owncloud.com>
Thu, 10 Oct 2013 09:34:30 +0000 (11:34 +0200)
1  2 
lib/private/files/view.php
tests/lib/files/view.php

Simple merge
index e2107a03614a3f280a4f9a892c5bcfa449ac5f43,a5107c351f4468c5a3ba95f2fbdffb37e5852254..b2dd3963f1c301400348f3c41dfbce5668259e4e
@@@ -392,21 -392,28 +392,46 @@@ class View extends \PHPUnit_Framework_T
                return $storage;
        }
  
+       private $createHookPath;
+       function dummyCreateHook($params) {
+               $this->createHookPath = $params['path'];
+       }
 +      /**
 +       * @medium
 +       */
 +      function testViewHooksIfRootStartsTheSame() {
 +              $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');
 +
 +              $subView = new \OC\Files\View($defaultRoot . '_substorage');
 +              $this->hookPath = null;
 +
 +              $subView->file_put_contents('/foo.txt', 'asd');
 +              $this->assertNull($this->hookPath);
 +      }
++
+       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');
+               $view = new \OC\Files\View($defaultRoot);
+               $this->hookPath = null;
+               $view->file_put_contents('/asd.txt', 'foo');
+               $this->assertEquals('/asd.txt', $this->createHookPath);
+               $this->createHookPath = null;
+               $view->file_put_contents('/asd.txt', 'foo');
+               $this->assertNull($this->createHookPath);
+       }
  }