diff options
Diffstat (limited to 'apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php')
-rw-r--r-- | apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php b/apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php new file mode 100644 index 00000000000..21e88e86f90 --- /dev/null +++ b/apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php @@ -0,0 +1,55 @@ +<?php + +declare(strict_types=1); +/** + * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +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\IUserManager; +use PHPUnit\Framework\MockObject\MockObject; +use Test\TestCase; + +class ExpireVersionsTest extends TestCase { + private IConfig&MockObject $config; + private IUserManager&MockObject $userManager; + private Expiration&MockObject $expiration; + private IJobList&MockObject $jobList; + + protected function setUp(): void { + parent::setUp(); + + $this->config = $this->createMock(IConfig::class); + $this->userManager = $this->createMock(IUserManager::class); + $this->expiration = $this->createMock(Expiration::class); + $this->jobList = $this->createMock(IJobList::class); + + $this->jobList->expects($this->once()) + ->method('setLastRun'); + $this->jobList->expects($this->once()) + ->method('setExecutionTime'); + } + + public function testBackgroundJobDeactivated(): void { + $this->config->method('getAppValue') + ->with('files_versions', 'background_job_expire_versions', 'yes') + ->willReturn('no'); + $this->expiration->expects($this->never()) + ->method('getMaxAgeAsTimestamp'); + + $timeFactory = $this->createMock(ITimeFactory::class); + $timeFactory->method('getTime') + ->with() + ->willReturn(999999999); + + $job = new ExpireVersions($this->config, $this->userManager, $this->expiration, $timeFactory); + $job->start($this->jobList); + } +} |