diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-07-18 11:21:03 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-08-08 17:03:51 +0200 |
commit | 49334e4d9c278d33ce9fd4195b5a12af99821be2 (patch) | |
tree | 45ffe11ad48be373ad7a46f4214d285b18a7670e /apps | |
parent | 48d9c4d2b093e12ec3bf3cd29295da0f2277028f (diff) | |
download | nextcloud-server-49334e4d9c278d33ce9fd4195b5a12af99821be2.tar.gz nextcloud-server-49334e4d9c278d33ce9fd4195b5a12af99821be2.zip |
Fix many tests and warnings
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps')
3 files changed, 33 insertions, 19 deletions
diff --git a/apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php b/apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php index d8cce61ca52..bf5d6bc65ae 100644 --- a/apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php +++ b/apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php @@ -48,9 +48,6 @@ class ExpireTrashTest extends TestCase { /** @var IJobList|MockObject */ private $jobList; - /** @var LoggerInterface|MockObject */ - private $logger; - /** @var ITimeFactory|MockObject */ private $time; @@ -61,8 +58,10 @@ class ExpireTrashTest 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->time = $this->createMock(ITimeFactory::class); + $this->time->method('getTime') + ->willReturn(99999999999); $this->jobList->expects($this->once()) ->method('setLastRun'); @@ -71,8 +70,12 @@ class ExpireTrashTest extends TestCase { } public function testConstructAndRun(): void { - $job = new ExpireTrash($this->config, $this->userManager, $this->expiration); - $job->execute($this->jobList, $this->logger); + $this->config->method('getAppValue') + ->with('files_trashbin', 'background_job_expire_trash', 'yes') + ->willReturn('yes'); + + $job = new ExpireTrash($this->config, $this->userManager, $this->expiration, $this->time); + $job->start($this->jobList); } public function testBackgroundJobDeactivated(): void { diff --git a/apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php b/apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php index ca584ae9f53..442a7020d89 100644 --- a/apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php +++ b/apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php @@ -28,7 +28,6 @@ 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; @@ -68,7 +67,12 @@ class ExpireVersionsTest extends TestCase { $this->expiration->expects($this->never()) ->method('getMaxAgeAsTimestamp'); - $job = new ExpireVersions($this->config, $this->userManager, $this->expiration, $this->createMock(ITimeFactory::class)); + $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); } } diff --git a/apps/updatenotification/tests/Settings/AdminTest.php b/apps/updatenotification/tests/Settings/AdminTest.php index 852504fb45a..489679dfabd 100644 --- a/apps/updatenotification/tests/Settings/AdminTest.php +++ b/apps/updatenotification/tests/Settings/AdminTest.php @@ -36,13 +36,16 @@ use OCP\IConfig; use OCP\IDateTimeFormatter; use OCP\IGroup; use OCP\IGroupManager; +use OCP\IUserManager; use OCP\L10N\IFactory; use OCP\L10N\ILanguageIterator; use OCP\Support\Subscription\IRegistry; +use OCP\UserInterface; +use OCP\User\Backend\ICountUsersBackend; use OCP\Util; -use Test\TestCase; -use OCP\IUserManager; +use OC\User\Backend; use Psr\Log\LoggerInterface; +use Test\TestCase; class AdminTest extends TestCase { /** @var IFactory|\PHPUnit\Framework\MockObject\MockObject */ @@ -89,9 +92,9 @@ class AdminTest extends TestCase { } public function testGetFormWithUpdate() { - $backend1 = $this->createMock(UserInterface::class); - $backend2 = $this->createMock(UserInterface::class); - $backend3 = $this->createMock(UserInterface::class); + $backend1 = $this->createMock(CountUsersBackend::class); + $backend2 = $this->createMock(CountUsersBackend::class); + $backend3 = $this->createMock(CountUsersBackend::class); $backend1 ->expects($this->once()) ->method('implementsActions') @@ -213,9 +216,9 @@ class AdminTest extends TestCase { } public function testGetFormWithUpdateAndChangedUpdateServer() { - $backend1 = $this->createMock(UserInterface::class); - $backend2 = $this->createMock(UserInterface::class); - $backend3 = $this->createMock(UserInterface::class); + $backend1 = $this->createMock(CountUsersBackend::class); + $backend2 = $this->createMock(CountUsersBackend::class); + $backend3 = $this->createMock(CountUsersBackend::class); $backend1 ->expects($this->once()) ->method('implementsActions') @@ -337,9 +340,9 @@ class AdminTest extends TestCase { } public function testGetFormWithUpdateAndCustomersUpdateServer() { - $backend1 = $this->createMock(UserInterface::class); - $backend2 = $this->createMock(UserInterface::class); - $backend3 = $this->createMock(UserInterface::class); + $backend1 = $this->createMock(CountUsersBackend::class); + $backend2 = $this->createMock(CountUsersBackend::class); + $backend3 = $this->createMock(CountUsersBackend::class); $backend1 ->expects($this->once()) ->method('implementsActions') @@ -543,3 +546,7 @@ class AdminTest extends TestCase { $this->assertSame($expectation, $result); } } + +abstract class CountUsersBackend implements UserInterface, ICountUsersBackend { + +} |