diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2022-02-22 11:24:38 +0100 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2022-02-22 13:55:06 +0100 |
commit | c01eb0775648bd54e9cd4904499a30f448554968 (patch) | |
tree | c06b619b4af515e48db263af4d82cee18473ba31 /apps/dav/tests | |
parent | a6bc871c96d071ef54d9fd3b547df606fa9d19ca (diff) | |
download | nextcloud-server-c01eb0775648bd54e9cd4904499a30f448554968.tar.gz nextcloud-server-c01eb0775648bd54e9cd4904499a30f448554968.zip |
Mark DAV background jobs as time sensitive/insensitive
* As a bonus they are now all using OCP base classes
* Strict typing is now enforced
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/dav/tests')
5 files changed, 60 insertions, 20 deletions
diff --git a/apps/dav/tests/unit/BackgroundJob/EventReminderJobTest.php b/apps/dav/tests/unit/BackgroundJob/EventReminderJobTest.php index f9276b61956..ed3c324e710 100644 --- a/apps/dav/tests/unit/BackgroundJob/EventReminderJobTest.php +++ b/apps/dav/tests/unit/BackgroundJob/EventReminderJobTest.php @@ -30,27 +30,37 @@ namespace OCA\DAV\Tests\unit\BackgroundJob; use OCA\DAV\BackgroundJob\EventReminderJob; use OCA\DAV\CalDAV\Reminder\ReminderService; +use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; +use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; class EventReminderJobTest extends TestCase { - /** @var ReminderService|\PHPUnit\Framework\MockObject\MockObject */ + /** @var ITimeFactory|MockObject */ + private $time; + + /** @var ReminderService|MockObject */ private $reminderService; - /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IConfig|MockObject */ private $config; - /** @var EventReminderJob|\PHPUnit\Framework\MockObject\MockObject */ + /** @var EventReminderJob|MockObject */ private $backgroundJob; protected function setUp(): void { parent::setUp(); + $this->time = $this->createMock(ITimeFactory::class); $this->reminderService = $this->createMock(ReminderService::class); $this->config = $this->createMock(IConfig::class); - $this->backgroundJob = new EventReminderJob($this->reminderService, $this->config); + $this->backgroundJob = new EventReminderJob( + $this->time, + $this->reminderService, + $this->config, + ); } public function data(): array { diff --git a/apps/dav/tests/unit/BackgroundJob/GenerateBirthdayCalendarBackgroundJobTest.php b/apps/dav/tests/unit/BackgroundJob/GenerateBirthdayCalendarBackgroundJobTest.php index 6c6e02ce717..e0601c5c71a 100644 --- a/apps/dav/tests/unit/BackgroundJob/GenerateBirthdayCalendarBackgroundJobTest.php +++ b/apps/dav/tests/unit/BackgroundJob/GenerateBirthdayCalendarBackgroundJobTest.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * @copyright Copyright (c) 2017, Georg Ehrke * @@ -27,15 +30,20 @@ namespace OCA\DAV\Tests\unit\BackgroundJob; use OCA\DAV\BackgroundJob\GenerateBirthdayCalendarBackgroundJob; use OCA\DAV\CalDAV\BirthdayService; +use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; +use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; class GenerateBirthdayCalendarBackgroundJobTest extends TestCase { - /** @var BirthdayService | \PHPUnit\Framework\MockObject\MockObject */ + /** @var ITimeFactory|MockObject */ + private $time; + + /** @var BirthdayService | MockObject */ private $birthdayService; - /** @var IConfig | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IConfig | MockObject */ private $config; /** @var \OCA\DAV\BackgroundJob\GenerateBirthdayCalendarBackgroundJob */ @@ -44,11 +52,15 @@ class GenerateBirthdayCalendarBackgroundJobTest extends TestCase { protected function setUp(): void { parent::setUp(); + $this->time = $this->createMock(ITimeFactory::class); $this->birthdayService = $this->createMock(BirthdayService::class); $this->config = $this->createMock(IConfig::class); $this->backgroundJob = new GenerateBirthdayCalendarBackgroundJob( - $this->birthdayService, $this->config); + $this->time, + $this->birthdayService, + $this->config, + ); } public function testRun() { diff --git a/apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php b/apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php index eba2a21f761..360c4c791c7 100644 --- a/apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php +++ b/apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * @copyright Copyright (c) 2018, Georg Ehrke * diff --git a/apps/dav/tests/unit/BackgroundJob/RegisterRegenerateBirthdayCalendarsTest.php b/apps/dav/tests/unit/BackgroundJob/RegisterRegenerateBirthdayCalendarsTest.php index f3b1878a833..00931d53f64 100644 --- a/apps/dav/tests/unit/BackgroundJob/RegisterRegenerateBirthdayCalendarsTest.php +++ b/apps/dav/tests/unit/BackgroundJob/RegisterRegenerateBirthdayCalendarsTest.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * @copyright 2019 Georg Ehrke <oc.list@georgehrke.com> * @@ -45,9 +48,6 @@ class RegisterRegenerateBirthdayCalendarsTest extends TestCase { /** @var IJobList | \PHPUnit\Framework\MockObject\MockObject */ private $jobList; - /** @var IConfig | \PHPUnit\Framework\MockObject\MockObject */ - private $config; - /** @var RegisterRegenerateBirthdayCalendars */ private $backgroundJob; @@ -57,10 +57,12 @@ class RegisterRegenerateBirthdayCalendarsTest extends TestCase { $this->time = $this->createMock(ITimeFactory::class); $this->userManager = $this->createMock(IUserManager::class); $this->jobList = $this->createMock(IJobList::class); - $this->config = $this->createMock(IConfig::class); - $this->backgroundJob = new RegisterRegenerateBirthdayCalendars($this->time, - $this->userManager, $this->jobList); + $this->backgroundJob = new RegisterRegenerateBirthdayCalendars( + $this->time, + $this->userManager, + $this->jobList + ); } public function testRun() { diff --git a/apps/dav/tests/unit/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJobTest.php b/apps/dav/tests/unit/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJobTest.php index 5974d0dec99..59b68452862 100644 --- a/apps/dav/tests/unit/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJobTest.php +++ b/apps/dav/tests/unit/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJobTest.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * @copyright Copyright (c) 2018, Georg Ehrke * @@ -29,12 +32,14 @@ namespace OCA\DAV\Tests\unit\BackgroundJob; use OCA\DAV\BackgroundJob\UpdateCalendarResourcesRoomsBackgroundJob; use OCA\DAV\CalDAV\CalDavBackend; +use OCP\AppFramework\Utility\ITimeFactory; use OCP\Calendar\BackendTemporarilyUnavailableException; use OCP\Calendar\IMetadataProvider; use OCP\Calendar\Resource\IBackend; use OCP\Calendar\Resource\IManager as IResourceManager; use OCP\Calendar\Resource\IResource; use OCP\Calendar\Room\IManager as IRoomManager; +use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; interface tmpI extends IResource, IMetadataProvider { @@ -42,28 +47,36 @@ interface tmpI extends IResource, IMetadataProvider { class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase { - /** @var UpdateCalendarResourcesRoomsBackgroundJob */ - private $backgroundJob; + /** @var ITimeFactory|MockObject */ + private $time; - /** @var IResourceManager | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IResourceManager|MockObject */ private $resourceManager; - /** @var IRoomManager | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IRoomManager|MockObject */ private $roomManager; - /** @var CalDavBackend | \PHPUnit\Framework\MockObject\MockObject */ + /** @var CalDavBackend|MockObject */ private $calDavBackend; + /** @var UpdateCalendarResourcesRoomsBackgroundJob */ + private $backgroundJob; + protected function setUp(): void { parent::setUp(); + $this->time = $this->createMock(ITimeFactory::class); $this->resourceManager = $this->createMock(IResourceManager::class); $this->roomManager = $this->createMock(IRoomManager::class); $this->calDavBackend = $this->createMock(CalDavBackend::class); $this->backgroundJob = new UpdateCalendarResourcesRoomsBackgroundJob( - $this->resourceManager, $this->roomManager, self::$realDatabase, - $this->calDavBackend); + $this->time, + $this->resourceManager, + $this->roomManager, + self::$realDatabase, + $this->calDavBackend + ); } protected function tearDown(): void { |