set retention obligation on existing expiration
in tests
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
e225a7bfd3
commit
964dc0a955
4 changed files with 16 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue