diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-06-28 12:55:26 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-08-08 17:03:19 +0200 |
commit | 48d9c4d2b093e12ec3bf3cd29295da0f2277028f (patch) | |
tree | d66f1d2f54e8ae745fc7ce7bf067ce2072eeac6a /apps/files_versions | |
parent | 19a2d6f6e7d54eb9318279809bf6c3f40bf566e2 (diff) | |
download | nextcloud-server-48d9c4d2b093e12ec3bf3cd29295da0f2277028f.tar.gz nextcloud-server-48d9c4d2b093e12ec3bf3cd29295da0f2277028f.zip |
Port existing server code to new interface
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/files_versions')
-rw-r--r-- | apps/files_versions/lib/BackgroundJob/ExpireVersions.php | 26 | ||||
-rw-r--r-- | apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php | 9 |
2 files changed, 12 insertions, 23 deletions
diff --git a/apps/files_versions/lib/BackgroundJob/ExpireVersions.php b/apps/files_versions/lib/BackgroundJob/ExpireVersions.php index a8a311f0a05..7e714a059d0 100644 --- a/apps/files_versions/lib/BackgroundJob/ExpireVersions.php +++ b/apps/files_versions/lib/BackgroundJob/ExpireVersions.php @@ -27,27 +27,21 @@ namespace OCA\Files_Versions\BackgroundJob; use OCA\Files_Versions\Expiration; use OCA\Files_Versions\Storage; +use OCP\AppFramework\Utility\ITimeFactory; +use OCP\BackgroundJob\TimedJob; use OCP\IConfig; use OCP\IUser; use OCP\IUserManager; -class ExpireVersions extends \OC\BackgroundJob\TimedJob { +class ExpireVersions extends TimedJob { public const ITEMS_PER_SESSION = 1000; - /** @var IConfig */ - private $config; + private IConfig $config; + private Expiration $expiration; + private IUserManager $userManager; - /** - * @var Expiration - */ - private $expiration; - - /** - * @var IUserManager - */ - private $userManager; - - public function __construct(IConfig $config, IUserManager $userManager, Expiration $expiration) { + public function __construct(IConfig $config, IUserManager $userManager, Expiration $expiration, ITimeFactory $time) { + parent::__construct($time); // Run once per 30 minutes $this->setInterval(60 * 30); @@ -78,10 +72,8 @@ class ExpireVersions extends \OC\BackgroundJob\TimedJob { /** * Act on behalf on trash item owner - * @param string $user - * @return boolean */ - protected function setupFS($user) { + protected function setupFS(string $user): bool { \OC_Util::tearDownFS(); \OC_Util::setupFS($user); diff --git a/apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php b/apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php index a1acffb8543..ca584ae9f53 100644 --- a/apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php +++ b/apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php @@ -25,6 +25,7 @@ namespace OCA\Files_Versions\Tests\BackgroundJob; use OCA\Files_Versions\BackgroundJob\ExpireVersions; use OCA\Files_Versions\Expiration; +use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJobList; use OCP\IConfig; use OCP\ILogger; @@ -46,9 +47,6 @@ class ExpireVersionsTest extends TestCase { /** @var IJobList|MockObject */ private $jobList; - /** @var ILogger|MockObject */ - private $logger; - protected function setUp(): void { parent::setUp(); @@ -56,7 +54,6 @@ class ExpireVersionsTest extends TestCase { $this->userManager = $this->createMock(IUserManager::class); $this->expiration = $this->createMock(Expiration::class); $this->jobList = $this->createMock(IJobList::class); - $this->logger = $this->createMock(ILogger::class); $this->jobList->expects($this->once()) ->method('setLastRun'); @@ -71,7 +68,7 @@ class ExpireVersionsTest extends TestCase { $this->expiration->expects($this->never()) ->method('getMaxAgeAsTimestamp'); - $job = new ExpireVersions($this->config, $this->userManager, $this->expiration); - $job->execute($this->jobList, $this->logger); + $job = new ExpireVersions($this->config, $this->userManager, $this->expiration, $this->createMock(ITimeFactory::class)); + $job->start($this->jobList); } } |