diff options
author | Robin Appelman <icewind@owncloud.com> | 2016-02-19 14:29:01 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2016-03-21 13:53:33 +0100 |
commit | d0dd76bb8ac904cff425d4c32f2033951e3a2ba5 (patch) | |
tree | acb6db47155822419c39eb3bfae0af52a2fd6e1f /apps/files_trashbin | |
parent | 6031ae1ad41cb39ac8783b4a95f98574c28c92f1 (diff) | |
download | nextcloud-server-d0dd76bb8ac904cff425d4c32f2033951e3a2ba5.tar.gz nextcloud-server-d0dd76bb8ac904cff425d4c32f2033951e3a2ba5.zip |
set watch policy in test
Diffstat (limited to 'apps/files_trashbin')
-rw-r--r-- | apps/files_trashbin/tests/trashbin.php | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/apps/files_trashbin/tests/trashbin.php b/apps/files_trashbin/tests/trashbin.php index 930f8c2bf3e..8d616b6e8e2 100644 --- a/apps/files_trashbin/tests/trashbin.php +++ b/apps/files_trashbin/tests/trashbin.php @@ -86,11 +86,12 @@ class Test_Trashbin extends \Test\TestCase { } - public static function tearDownAfterClass() { // cleanup test user $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); @@ -109,6 +110,18 @@ class Test_Trashbin extends \Test\TestCase { parent::setUp(); \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->trashRoot2 = '/' . self::TEST_TRASHBIN_USER2 . '/files_trashbin'; @@ -117,6 +130,7 @@ class Test_Trashbin extends \Test\TestCase { } protected function tearDown() { + $this->restoreService('AllConfig'); // disable trashbin to be able to properly clean up \OC::$server->getAppManager()->disableApp('files_trashbin'); @@ -138,8 +152,8 @@ class Test_Trashbin extends \Test\TestCase { public function testExpireOldFiles() { $currentTime = time(); - $expireAt = $currentTime - 2*24*60*60; - $expiredDate = $currentTime - 3*24*60*60; + $expireAt = $currentTime - 2 * 24 * 60 * 60; + $expiredDate = $currentTime - 3 * 24 * 60 * 60; // create some files \OC\Files\Filesystem::file_put_contents('file1.txt', 'file1'); @@ -187,7 +201,7 @@ class Test_Trashbin extends \Test\TestCase { $currentTime = time(); $folder = "trashTest-" . $currentTime . '/'; - $expiredDate = $currentTime - 3*24*60*60; + $expiredDate = $currentTime - 3 * 24 * 60 * 60; // create some files \OC\Files\Filesystem::mkdir($folder); @@ -250,6 +264,7 @@ class Test_Trashbin extends \Test\TestCase { /** * verify that the array contains the expected results + * * @param OCP\Files\FileInfo[] $result * @param string[] $expected */ @@ -265,7 +280,7 @@ class Test_Trashbin extends \Test\TestCase { } if (!$found) { // if we didn't found the expected file, something went wrong - $this->assertTrue(false, "can't find expected file '" . $expectedFile . "' in trash bin"); + $this->assertTrue(false, "can't find expected file '" . $expectedFile . "' in trash bin"); } } } @@ -281,7 +296,7 @@ class Test_Trashbin extends \Test\TestCase { // modify every second file $counter = ($counter + 1) % 2; 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); $this->rootView->rename($source, $target); $file['mtime'] = $expireDate; @@ -445,7 +460,7 @@ class Test_Trashbin extends \Test\TestCase { $trashedFile = $filesInTrash[0]; $this->assertTrue( - OCA\Files_Trashbin\Trashbin::restore( + OCA\Files_Trashbin\Trashbin::restore( 'folder.d' . $trashedFile->getMtime() . '/file1.txt', 'file1.txt', $trashedFile->getMtime() @@ -639,7 +654,7 @@ class Test_Trashbin extends \Test\TestCase { if ($create) { try { \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 } } |