diff options
author | Robin Appelman <robin@icewind.nl> | 2019-11-04 16:54:22 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2019-11-04 16:54:22 +0100 |
commit | 964dc0a95520efbf876e0113bfafc294f4f4b322 (patch) | |
tree | cbeca4596bf35a81721ee4a9aa83b14a0e5d9051 /apps/files_trashbin | |
parent | e225a7bfd33f4ff986c9adf1f237a1c9c6b597a4 (diff) | |
download | nextcloud-server-964dc0a95520efbf876e0113bfafc294f4f4b322.tar.gz nextcloud-server-964dc0a95520efbf876e0113bfafc294f4f4b322.zip |
set retention obligation on existing `expiration` in tests
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_trashbin')
-rw-r--r-- | apps/files_trashbin/lib/AppInfo/Application.php | 7 | ||||
-rw-r--r-- | apps/files_trashbin/lib/Expiration.php | 6 | ||||
-rw-r--r-- | apps/files_trashbin/lib/Trashbin.php | 5 | ||||
-rw-r--r-- | apps/files_trashbin/tests/TrashbinTest.php | 12 |
4 files changed, 16 insertions, 14 deletions
diff --git a/apps/files_trashbin/lib/AppInfo/Application.php b/apps/files_trashbin/lib/AppInfo/Application.php index 4baa82a6b4b..a2613a13b41 100644 --- a/apps/files_trashbin/lib/AppInfo/Application.php +++ b/apps/files_trashbin/lib/AppInfo/Application.php @@ -46,12 +46,7 @@ class Application extends App { /* * Register expiration */ - $container->registerService('Expiration', function($c) { - return new Expiration( - $c->query('ServerContainer')->getConfig(), - $c->query(ITimeFactory::class) - ); - }); + $container->registerAlias('Expiration', Expiration::class); /* * Register $principalBackend for the DAV collection diff --git a/apps/files_trashbin/lib/Expiration.php b/apps/files_trashbin/lib/Expiration.php index c7ad4e29f18..933375c9537 100644 --- a/apps/files_trashbin/lib/Expiration.php +++ b/apps/files_trashbin/lib/Expiration.php @@ -49,7 +49,11 @@ class Expiration { public function __construct(IConfig $config,ITimeFactory $timeFactory){ $this->timeFactory = $timeFactory; - $this->retentionObligation = $config->getSystemValue('trashbin_retention_obligation', 'auto'); + $this->setRetentionObligation($config->getSystemValue('trashbin_retention_obligation', 'auto')); + } + + public function setRetentionObligation(string $obligation) { + $this->retentionObligation = $obligation; if ($this->retentionObligation !== 'disabled') { $this->parseRetentionObligation(); diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index bb1c9c172ec..34138c21705 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -793,9 +793,8 @@ class Trashbin { * @return integer[] size of deleted files and number of deleted files */ public static function deleteExpiredFiles($files, $user) { - /** @var Application $application */ - $application = \OC::$server->query(Application::class); - $expiration = $application->getContainer()->query('Expiration'); + /** @var Expiration $expiration */ + $expiration = \OC::$server->query(Expiration::class); $size = 0; $count = 0; foreach ($files as $file) { diff --git a/apps/files_trashbin/tests/TrashbinTest.php b/apps/files_trashbin/tests/TrashbinTest.php index 3263feb4a95..22b6e87317c 100644 --- a/apps/files_trashbin/tests/TrashbinTest.php +++ b/apps/files_trashbin/tests/TrashbinTest.php @@ -76,7 +76,9 @@ class TrashbinTest extends \Test\TestCase { $config = \OC::$server->getConfig(); //configure trashbin self::$rememberRetentionObligation = $config->getSystemValue('trashbin_retention_obligation', \OCA\Files_Trashbin\Expiration::DEFAULT_RETENTION_OBLIGATION); - $config->setSystemValue('trashbin_retention_obligation', 'auto, 2'); + /** @var \OCA\Files_Trashbin\Expiration $expiration */ + $expiration = \OC::$server->query(\OCA\Files_Trashbin\Expiration::class); + $expiration->setRetentionObligation('auto, 2'); // register hooks \OCA\Files_Trashbin\Trashbin::registerHooks(); @@ -94,7 +96,9 @@ class TrashbinTest extends \Test\TestCase { $user->delete(); } - \OC::$server->getConfig()->setSystemValue('trashbin_retention_obligation', self::$rememberRetentionObligation); + /** @var \OCA\Files_Trashbin\Expiration $expiration */ + $expiration = \OC::$server->query(\OCA\Files_Trashbin\Expiration::class); + $expiration->setRetentionObligation(self::$rememberRetentionObligation); \OC_Hook::clear(); @@ -686,9 +690,9 @@ class TrashbinForTesting extends \OCA\Files_Trashbin\Trashbin { * @param OCP\Files\FileInfo[] $files * @param integer $limit */ - public function dummyDeleteExpiredFiles($files, $limit) { + public function dummyDeleteExpiredFiles($files) { // dummy value for $retention_obligation because it is not needed here - return parent::deleteExpiredFiles($files, TrashbinTest::TEST_TRASHBIN_USER1, $limit, 0); + return parent::deleteExpiredFiles($files, TrashbinTest::TEST_TRASHBIN_USER1); } /** |