Kaynağa Gözat

Update tests to test for create and update aswell

tags/v7.0.0alpha2
Joas Schilling 10 yıl önce
ebeveyn
işleme
39bf700790
1 değiştirilmiş dosya ile 35 ekleme ve 13 silme
  1. 35
    13
      tests/lib/files/view.php

+ 35
- 13
tests/lib/files/view.php Dosyayı Görüntüle

@@ -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');
}

/**

Loading…
İptal
Kaydet