Update tests to test for create and update aswell
This commit is contained in:
parent
c060f6ec7b
commit
39bf700790
|
@ -393,14 +393,15 @@ class View extends \PHPUnit_Framework_TestCase {
|
||||||
$rootView->file_put_contents('/foo.txt', 'asd');
|
$rootView->file_put_contents('/foo.txt', 'asd');
|
||||||
$this->assertNull($this->hookPath);
|
$this->assertNull($this->hookPath);
|
||||||
|
|
||||||
|
$this->hookWritePath = $this->hookUpdatePath = $this->hookCreatePath = null;
|
||||||
|
|
||||||
$subView->file_put_contents('/foo.txt', 'asd');
|
$subView->file_put_contents('/foo.txt', 'asd');
|
||||||
$this->assertNotNull($this->hookPath);
|
|
||||||
$this->assertEquals('/substorage/foo.txt', $this->hookPath);
|
$this->assertEquals('/substorage/foo.txt', $this->hookPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private $hookPath;
|
private $hookPath;
|
||||||
|
|
||||||
function dummyHook($params) {
|
public function dummyHook($params) {
|
||||||
$this->hookPath = $params['path'];
|
$this->hookPath = $params['path'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,12 +443,6 @@ class View extends \PHPUnit_Framework_TestCase {
|
||||||
return $storage;
|
return $storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private $createHookPath;
|
|
||||||
|
|
||||||
function dummyCreateHook($params) {
|
|
||||||
$this->createHookPath = $params['path'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @medium
|
* @medium
|
||||||
*/
|
*/
|
||||||
|
@ -466,23 +461,50 @@ class View extends \PHPUnit_Framework_TestCase {
|
||||||
$this->assertNull($this->hookPath);
|
$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() {
|
public function testEditNoCreateHook() {
|
||||||
$storage1 = $this->getTestStorage();
|
$storage1 = $this->getTestStorage();
|
||||||
$storage2 = $this->getTestStorage();
|
$storage2 = $this->getTestStorage();
|
||||||
$defaultRoot = \OC\Files\Filesystem::getRoot();
|
$defaultRoot = \OC\Files\Filesystem::getRoot();
|
||||||
\OC\Files\Filesystem::mount($storage1, array(), '/');
|
\OC\Files\Filesystem::mount($storage1, array(), '/');
|
||||||
\OC\Files\Filesystem::mount($storage2, array(), $defaultRoot);
|
\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);
|
$view = new \OC\Files\View($defaultRoot);
|
||||||
$this->hookPath = null;
|
$this->hookWritePath = $this->hookUpdatePath = $this->hookCreatePath = null;
|
||||||
|
|
||||||
$view->file_put_contents('/asd.txt', 'foo');
|
$view->file_put_contents('/asd.txt', 'foo');
|
||||||
$this->assertEquals('/asd.txt', $this->createHookPath);
|
$this->assertEquals('/asd.txt', $this->hookCreatePath);
|
||||||
$this->createHookPath = null;
|
$this->assertNull($this->hookUpdatePath);
|
||||||
|
$this->assertEquals('/asd.txt', $this->hookWritePath);
|
||||||
|
|
||||||
|
$this->hookWritePath = $this->hookUpdatePath = $this->hookCreatePath = null;
|
||||||
|
|
||||||
$view->file_put_contents('/asd.txt', 'foo');
|
$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');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue