summaryrefslogtreecommitdiffstats
path: root/apps/files_versions
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-08-23 16:55:42 +0200
committerGitHub <noreply@github.com>2022-08-23 16:55:42 +0200
commitb888c6146327d842e21988b0d90d6ade4f3a9435 (patch)
treeaa115b3d420cb6ccfa18a6a5af146eff8578b82c /apps/files_versions
parent5f90a6a5e2da08e7098cc44937c1713375823e74 (diff)
parent49334e4d9c278d33ce9fd4195b5a12af99821be2 (diff)
downloadnextcloud-server-b888c6146327d842e21988b0d90d6ade4f3a9435.tar.gz
nextcloud-server-b888c6146327d842e21988b0d90d6ade4f3a9435.zip
Merge pull request #33047 from nextcloud/fix/ijob-logger-deprecated
Deprecated ILogger from IJob
Diffstat (limited to 'apps/files_versions')
-rw-r--r--apps/files_versions/lib/BackgroundJob/ExpireVersions.php26
-rw-r--r--apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php15
2 files changed, 17 insertions, 24 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..442a7020d89 100644
--- a/apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php
+++ b/apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php
@@ -25,9 +25,9 @@ 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;
use OCP\IUserManager;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
@@ -46,9 +46,6 @@ class ExpireVersionsTest extends TestCase {
/** @var IJobList|MockObject */
private $jobList;
- /** @var ILogger|MockObject */
- private $logger;
-
protected function setUp(): void {
parent::setUp();
@@ -56,7 +53,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 +67,12 @@ 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);
+ $timeFactory = $this->createMock(ITimeFactory::class);
+ $timeFactory->method('getTime')
+ ->with()
+ ->willReturn(99999999999);
+
+ $job = new ExpireVersions($this->config, $this->userManager, $this->expiration, $timeFactory);
+ $job->start($this->jobList);
}
}