set watch policy in test
This commit is contained in:
parent
6031ae1ad4
commit
d0dd76bb8a
|
@ -86,11 +86,12 @@ class Test_Trashbin extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function tearDownAfterClass() {
|
public static function tearDownAfterClass() {
|
||||||
// cleanup test user
|
// cleanup test user
|
||||||
$user = \OC::$server->getUserManager()->get(self::TEST_TRASHBIN_USER1);
|
$user = \OC::$server->getUserManager()->get(self::TEST_TRASHBIN_USER1);
|
||||||
if ($user !== null) { $user->delete(); }
|
if ($user !== null) {
|
||||||
|
$user->delete();
|
||||||
|
}
|
||||||
|
|
||||||
\OC::$server->getConfig()->setSystemValue('trashbin_retention_obligation', self::$rememberRetentionObligation);
|
\OC::$server->getConfig()->setSystemValue('trashbin_retention_obligation', self::$rememberRetentionObligation);
|
||||||
|
|
||||||
|
@ -109,6 +110,18 @@ class Test_Trashbin extends \Test\TestCase {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
\OC::$server->getAppManager()->enableApp('files_trashbin');
|
\OC::$server->getAppManager()->enableApp('files_trashbin');
|
||||||
|
$config = \OC::$server->getConfig();
|
||||||
|
$mockConfig = $this->getMock('\OCP\IConfig');
|
||||||
|
$mockConfig->expects($this->any())
|
||||||
|
->method('getSystemValue')
|
||||||
|
->will($this->returnCallback(function ($key, $default) use ($config) {
|
||||||
|
if ($key === 'filesystem_check_changes') {
|
||||||
|
return \OC\Files\Cache\Watcher::CHECK_ONCE;
|
||||||
|
} else {
|
||||||
|
return $config->getSystemValue($key, $default);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
$this->overwriteService('AllConfig', $mockConfig);
|
||||||
|
|
||||||
$this->trashRoot1 = '/' . self::TEST_TRASHBIN_USER1 . '/files_trashbin';
|
$this->trashRoot1 = '/' . self::TEST_TRASHBIN_USER1 . '/files_trashbin';
|
||||||
$this->trashRoot2 = '/' . self::TEST_TRASHBIN_USER2 . '/files_trashbin';
|
$this->trashRoot2 = '/' . self::TEST_TRASHBIN_USER2 . '/files_trashbin';
|
||||||
|
@ -117,6 +130,7 @@ class Test_Trashbin extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown() {
|
protected function tearDown() {
|
||||||
|
$this->restoreService('AllConfig');
|
||||||
// disable trashbin to be able to properly clean up
|
// disable trashbin to be able to properly clean up
|
||||||
\OC::$server->getAppManager()->disableApp('files_trashbin');
|
\OC::$server->getAppManager()->disableApp('files_trashbin');
|
||||||
|
|
||||||
|
@ -138,8 +152,8 @@ class Test_Trashbin extends \Test\TestCase {
|
||||||
public function testExpireOldFiles() {
|
public function testExpireOldFiles() {
|
||||||
|
|
||||||
$currentTime = time();
|
$currentTime = time();
|
||||||
$expireAt = $currentTime - 2*24*60*60;
|
$expireAt = $currentTime - 2 * 24 * 60 * 60;
|
||||||
$expiredDate = $currentTime - 3*24*60*60;
|
$expiredDate = $currentTime - 3 * 24 * 60 * 60;
|
||||||
|
|
||||||
// create some files
|
// create some files
|
||||||
\OC\Files\Filesystem::file_put_contents('file1.txt', 'file1');
|
\OC\Files\Filesystem::file_put_contents('file1.txt', 'file1');
|
||||||
|
@ -187,7 +201,7 @@ class Test_Trashbin extends \Test\TestCase {
|
||||||
|
|
||||||
$currentTime = time();
|
$currentTime = time();
|
||||||
$folder = "trashTest-" . $currentTime . '/';
|
$folder = "trashTest-" . $currentTime . '/';
|
||||||
$expiredDate = $currentTime - 3*24*60*60;
|
$expiredDate = $currentTime - 3 * 24 * 60 * 60;
|
||||||
|
|
||||||
// create some files
|
// create some files
|
||||||
\OC\Files\Filesystem::mkdir($folder);
|
\OC\Files\Filesystem::mkdir($folder);
|
||||||
|
@ -250,6 +264,7 @@ class Test_Trashbin extends \Test\TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* verify that the array contains the expected results
|
* verify that the array contains the expected results
|
||||||
|
*
|
||||||
* @param OCP\Files\FileInfo[] $result
|
* @param OCP\Files\FileInfo[] $result
|
||||||
* @param string[] $expected
|
* @param string[] $expected
|
||||||
*/
|
*/
|
||||||
|
@ -281,7 +296,7 @@ class Test_Trashbin extends \Test\TestCase {
|
||||||
// modify every second file
|
// modify every second file
|
||||||
$counter = ($counter + 1) % 2;
|
$counter = ($counter + 1) % 2;
|
||||||
if ($counter === 1) {
|
if ($counter === 1) {
|
||||||
$source = $trashRoot . '/files/' . $file['name'].'.d'.$file['mtime'];
|
$source = $trashRoot . '/files/' . $file['name'] . '.d' . $file['mtime'];
|
||||||
$target = \OC\Files\Filesystem::normalizePath($trashRoot . '/files/' . $file['name'] . '.d' . $expireDate);
|
$target = \OC\Files\Filesystem::normalizePath($trashRoot . '/files/' . $file['name'] . '.d' . $expireDate);
|
||||||
$this->rootView->rename($source, $target);
|
$this->rootView->rename($source, $target);
|
||||||
$file['mtime'] = $expireDate;
|
$file['mtime'] = $expireDate;
|
||||||
|
@ -639,7 +654,7 @@ class Test_Trashbin extends \Test\TestCase {
|
||||||
if ($create) {
|
if ($create) {
|
||||||
try {
|
try {
|
||||||
\OC::$server->getUserManager()->createUser($user, $user);
|
\OC::$server->getUserManager()->createUser($user, $user);
|
||||||
} catch(\Exception $e) { // catch username is already being used from previous aborted runs
|
} catch (\Exception $e) { // catch username is already being used from previous aborted runs
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,19 @@ class Test_Files_Versioning extends \Test\TestCase {
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
$config = \OC::$server->getConfig();
|
||||||
|
$mockConfig = $this->getMock('\OCP\IConfig');
|
||||||
|
$mockConfig->expects($this->any())
|
||||||
|
->method('getSystemValue')
|
||||||
|
->will($this->returnCallback(function ($key, $default) use ($config) {
|
||||||
|
if ($key === 'filesystem_check_changes') {
|
||||||
|
return \OC\Files\Cache\Watcher::CHECK_ONCE;
|
||||||
|
} else {
|
||||||
|
return $config->getSystemValue($key, $default);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
$this->overwriteService('AllConfig', $mockConfig);
|
||||||
|
|
||||||
// clear hooks
|
// clear hooks
|
||||||
\OC_Hook::clear();
|
\OC_Hook::clear();
|
||||||
\OC::registerShareHooks();
|
\OC::registerShareHooks();
|
||||||
|
@ -87,6 +100,8 @@ class Test_Files_Versioning extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown() {
|
protected function tearDown() {
|
||||||
|
$this->restoreService('AllConfig');
|
||||||
|
|
||||||
if ($this->rootView) {
|
if ($this->rootView) {
|
||||||
$this->rootView->deleteAll(self::TEST_VERSIONS_USER . '/files/');
|
$this->rootView->deleteAll(self::TEST_VERSIONS_USER . '/files/');
|
||||||
$this->rootView->deleteAll(self::TEST_VERSIONS_USER2 . '/files/');
|
$this->rootView->deleteAll(self::TEST_VERSIONS_USER2 . '/files/');
|
||||||
|
|
Loading…
Reference in New Issue