aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/files/view.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-04-28 10:49:35 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-04-29 10:34:28 +0200
commit39bf700790bb403948e6821499b4ada0d3314610 (patch)
treec8e0d4e0aa3b1621d7dbe1a972e17e8e34649b06 /tests/lib/files/view.php
parentc060f6ec7b863c4b1bac5fa6b5383acf55f691de (diff)
downloadnextcloud-server-39bf700790bb403948e6821499b4ada0d3314610.tar.gz
nextcloud-server-39bf700790bb403948e6821499b4ada0d3314610.zip
Update tests to test for create and update aswell
Diffstat (limited to 'tests/lib/files/view.php')
-rw-r--r--tests/lib/files/view.php48
1 files changed, 35 insertions, 13 deletions
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index c85f1128dbe..682f3bb52af 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -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');
}
/**