aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/BackgroundJob
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/tests/unit/BackgroundJob')
-rw-r--r--apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php12
-rw-r--r--apps/dav/tests/unit/BackgroundJob/CleanupOrphanedChildrenJobTest.php31
-rw-r--r--apps/dav/tests/unit/BackgroundJob/EventReminderJobTest.php29
-rw-r--r--apps/dav/tests/unit/BackgroundJob/GenerateBirthdayCalendarBackgroundJobTest.php16
-rw-r--r--apps/dav/tests/unit/BackgroundJob/OutOfOfficeEventDispatcherJobTest.php20
-rw-r--r--apps/dav/tests/unit/BackgroundJob/PruneOutdatedSyncTokensJobTest.php22
-rw-r--r--apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php22
-rw-r--r--apps/dav/tests/unit/BackgroundJob/RegisterRegenerateBirthdayCalendarsTest.php48
-rw-r--r--apps/dav/tests/unit/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJobTest.php12
-rw-r--r--apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php19
10 files changed, 83 insertions, 148 deletions
diff --git a/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php b/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php
index 21e999d34be..b2199e3e657 100644
--- a/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php
+++ b/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php
@@ -13,17 +13,13 @@ use OCP\AppFramework\Utility\ITimeFactory;
use OCP\DB\QueryBuilder\IExpressionBuilder;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class CleanupInvitationTokenJobTest extends TestCase {
- /** @var IDBConnection | \PHPUnit\Framework\MockObject\MockObject */
- private $dbConnection;
-
- /** @var ITimeFactory | \PHPUnit\Framework\MockObject\MockObject */
- private $timeFactory;
-
- /** @var CleanupInvitationTokenJob */
- private $backgroundJob;
+ private IDBConnection&MockObject $dbConnection;
+ private ITimeFactory&MockObject $timeFactory;
+ private CleanupInvitationTokenJob $backgroundJob;
protected function setUp(): void {
parent::setUp();
diff --git a/apps/dav/tests/unit/BackgroundJob/CleanupOrphanedChildrenJobTest.php b/apps/dav/tests/unit/BackgroundJob/CleanupOrphanedChildrenJobTest.php
index fe05616d609..2065b8fe946 100644
--- a/apps/dav/tests/unit/BackgroundJob/CleanupOrphanedChildrenJobTest.php
+++ b/apps/dav/tests/unit/BackgroundJob/CleanupOrphanedChildrenJobTest.php
@@ -103,14 +103,13 @@ class CleanupOrphanedChildrenJobTest extends TestCase {
$deleteQb = $this->getMockQueryBuilder();
$result = $this->createMock(IResult::class);
- $qbInvocationCount = self::exactly(2);
- $this->connection->expects($qbInvocationCount)
- ->method('getQueryBuilder')
- ->willReturnCallback(function () use ($qbInvocationCount, $selectQb, $deleteQb) {
- return match ($qbInvocationCount->getInvocationCount()) {
- 1 => $selectQb,
- 2 => $deleteQb,
- };
+ $calls = [
+ $selectQb,
+ $deleteQb,
+ ];
+ $this->connection->method('getQueryBuilder')
+ ->willReturnCallback(function () use (&$calls) {
+ return array_shift($calls);
});
$selectQb->expects(self::once())
->method('executeQuery')
@@ -140,15 +139,15 @@ class CleanupOrphanedChildrenJobTest extends TestCase {
$deleteQb = $this->getMockQueryBuilder();
$result = $this->createMock(IResult::class);
- $qbInvocationCount = self::exactly(2);
- $this->connection->expects($qbInvocationCount)
- ->method('getQueryBuilder')
- ->willReturnCallback(function () use ($qbInvocationCount, $selectQb, $deleteQb) {
- return match ($qbInvocationCount->getInvocationCount()) {
- 1 => $selectQb,
- 2 => $deleteQb,
- };
+ $calls = [
+ $selectQb,
+ $deleteQb,
+ ];
+ $this->connection->method('getQueryBuilder')
+ ->willReturnCallback(function () use (&$calls) {
+ return array_shift($calls);
});
+
$selectQb->expects(self::once())
->method('executeQuery')
->willReturn($result);
diff --git a/apps/dav/tests/unit/BackgroundJob/EventReminderJobTest.php b/apps/dav/tests/unit/BackgroundJob/EventReminderJobTest.php
index 1173e516a22..1f70869f211 100644
--- a/apps/dav/tests/unit/BackgroundJob/EventReminderJobTest.php
+++ b/apps/dav/tests/unit/BackgroundJob/EventReminderJobTest.php
@@ -16,17 +16,10 @@ use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class EventReminderJobTest extends TestCase {
- /** @var ITimeFactory|MockObject */
- private $time;
-
- /** @var ReminderService|MockObject */
- private $reminderService;
-
- /** @var IConfig|MockObject */
- private $config;
-
- /** @var EventReminderJob|MockObject */
- private $backgroundJob;
+ private ITimeFactory&MockObject $time;
+ private ReminderService&MockObject $reminderService;
+ private IConfig&MockObject $config;
+ private EventReminderJob $backgroundJob;
protected function setUp(): void {
parent::setUp();
@@ -42,7 +35,7 @@ class EventReminderJobTest extends TestCase {
);
}
- public function data(): array {
+ public static function data(): array {
return [
[true, true, true],
[true, false, false],
@@ -61,14 +54,10 @@ class EventReminderJobTest extends TestCase {
public function testRun(bool $sendEventReminders, bool $sendEventRemindersMode, bool $expectCall): void {
$this->config->expects($this->exactly($sendEventReminders ? 2 : 1))
->method('getAppValue')
- ->withConsecutive(
- ['dav', 'sendEventReminders', 'yes'],
- ['dav', 'sendEventRemindersMode', 'backgroundjob'],
- )
- ->willReturnOnConsecutiveCalls(
- $sendEventReminders ? 'yes' : 'no',
- $sendEventRemindersMode ? 'backgroundjob' : 'cron'
- );
+ ->willReturnMap([
+ ['dav', 'sendEventReminders', 'yes', ($sendEventReminders ? 'yes' : 'no')],
+ ['dav', 'sendEventRemindersMode', 'backgroundjob', ($sendEventRemindersMode ? 'backgroundjob' : 'cron')],
+ ]);
if ($expectCall) {
$this->reminderService->expects($this->once())
diff --git a/apps/dav/tests/unit/BackgroundJob/GenerateBirthdayCalendarBackgroundJobTest.php b/apps/dav/tests/unit/BackgroundJob/GenerateBirthdayCalendarBackgroundJobTest.php
index 82d2251f17a..88a76ae1332 100644
--- a/apps/dav/tests/unit/BackgroundJob/GenerateBirthdayCalendarBackgroundJobTest.php
+++ b/apps/dav/tests/unit/BackgroundJob/GenerateBirthdayCalendarBackgroundJobTest.php
@@ -16,18 +16,10 @@ use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class GenerateBirthdayCalendarBackgroundJobTest extends TestCase {
-
- /** @var ITimeFactory|MockObject */
- private $time;
-
- /** @var BirthdayService | MockObject */
- private $birthdayService;
-
- /** @var IConfig | MockObject */
- private $config;
-
- /** @var GenerateBirthdayCalendarBackgroundJob */
- private $backgroundJob;
+ private ITimeFactory&MockObject $time;
+ private BirthdayService&MockObject $birthdayService;
+ private IConfig&MockObject $config;
+ private GenerateBirthdayCalendarBackgroundJob $backgroundJob;
protected function setUp(): void {
parent::setUp();
diff --git a/apps/dav/tests/unit/BackgroundJob/OutOfOfficeEventDispatcherJobTest.php b/apps/dav/tests/unit/BackgroundJob/OutOfOfficeEventDispatcherJobTest.php
index 5ddd9eba6f8..6135fd00fdc 100644
--- a/apps/dav/tests/unit/BackgroundJob/OutOfOfficeEventDispatcherJobTest.php
+++ b/apps/dav/tests/unit/BackgroundJob/OutOfOfficeEventDispatcherJobTest.php
@@ -25,21 +25,11 @@ use Test\TestCase;
class OutOfOfficeEventDispatcherJobTest extends TestCase {
private OutOfOfficeEventDispatcherJob $job;
-
- /** @var MockObject|ITimeFactory */
- private $timeFactory;
-
- /** @var MockObject|AbsenceMapper */
- private $absenceMapper;
-
- /** @var MockObject|LoggerInterface */
- private $logger;
-
- /** @var MockObject|IEventDispatcher */
- private $eventDispatcher;
-
- /** @var MockObject|IUserManager */
- private $userManager;
+ private ITimeFactory&MockObject $timeFactory;
+ private AbsenceMapper&MockObject $absenceMapper;
+ private LoggerInterface&MockObject $logger;
+ private IEventDispatcher&MockObject $eventDispatcher;
+ private IUserManager&MockObject $userManager;
private MockObject|TimezoneService $timezoneService;
protected function setUp(): void {
diff --git a/apps/dav/tests/unit/BackgroundJob/PruneOutdatedSyncTokensJobTest.php b/apps/dav/tests/unit/BackgroundJob/PruneOutdatedSyncTokensJobTest.php
index d08d0fd4496..eb471189c24 100644
--- a/apps/dav/tests/unit/BackgroundJob/PruneOutdatedSyncTokensJobTest.php
+++ b/apps/dav/tests/unit/BackgroundJob/PruneOutdatedSyncTokensJobTest.php
@@ -20,21 +20,11 @@ use Psr\Log\LoggerInterface;
use Test\TestCase;
class PruneOutdatedSyncTokensJobTest extends TestCase {
- /** @var ITimeFactory | MockObject */
- private $timeFactory;
-
- /** @var CalDavBackend | MockObject */
- private $calDavBackend;
-
- /** @var CardDavBackend | MockObject */
- private $cardDavBackend;
-
- /** @var IConfig|MockObject */
- private $config;
-
- /** @var LoggerInterface|MockObject */
- private $logger;
-
+ private ITimeFactory&MockObject $timeFactory;
+ private CalDavBackend&MockObject $calDavBackend;
+ private CardDavBackend&MockObject $cardDavBackend;
+ private IConfig&MockObject $config;
+ private LoggerInterface&MockObject $logger;
private PruneOutdatedSyncTokensJob $backgroundJob;
protected function setUp(): void {
@@ -84,7 +74,7 @@ class PruneOutdatedSyncTokensJobTest extends TestCase {
$this->backgroundJob->run(null);
}
- public function dataForTestRun(): array {
+ public static function dataForTestRun(): array {
return [
['100', '2', 100, 7 * 24 * 3600, 2, 3],
['100', '14', 100, 14 * 24 * 3600, 2, 3],
diff --git a/apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php b/apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php
index 2b11223210e..0cdeb6436e2 100644
--- a/apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php
+++ b/apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php
@@ -19,20 +19,11 @@ use Psr\Log\LoggerInterface;
use Test\TestCase;
class RefreshWebcalJobTest extends TestCase {
-
- /** @var RefreshWebcalService | MockObject */
- private $refreshWebcalService;
-
- /** @var IConfig | MockObject */
- private $config;
-
+ private RefreshWebcalService&MockObject $refreshWebcalService;
+ private IConfig&MockObject $config;
private LoggerInterface $logger;
-
- /** @var ITimeFactory | MockObject */
- private $timeFactory;
-
- /** @var IJobList | MockObject */
- private $jobList;
+ private ITimeFactory&MockObject $timeFactory;
+ private IJobList&MockObject $jobList;
protected function setUp(): void {
parent::setUp();
@@ -97,10 +88,7 @@ class RefreshWebcalJobTest extends TestCase {
$backgroundJob->start($this->jobList);
}
- /**
- * @return array
- */
- public function runDataProvider():array {
+ public static function runDataProvider():array {
return [
[0, 100000, true],
[100000, 100000, false]
diff --git a/apps/dav/tests/unit/BackgroundJob/RegisterRegenerateBirthdayCalendarsTest.php b/apps/dav/tests/unit/BackgroundJob/RegisterRegenerateBirthdayCalendarsTest.php
index 88493d91d9b..6c9214d0268 100644
--- a/apps/dav/tests/unit/BackgroundJob/RegisterRegenerateBirthdayCalendarsTest.php
+++ b/apps/dav/tests/unit/BackgroundJob/RegisterRegenerateBirthdayCalendarsTest.php
@@ -14,20 +14,14 @@ use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\IUser;
use OCP\IUserManager;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class RegisterRegenerateBirthdayCalendarsTest extends TestCase {
- /** @var ITimeFactory | \PHPUnit\Framework\MockObject\MockObject */
- private $time;
-
- /** @var IUserManager | \PHPUnit\Framework\MockObject\MockObject */
- private $userManager;
-
- /** @var IJobList | \PHPUnit\Framework\MockObject\MockObject */
- private $jobList;
-
- /** @var RegisterRegenerateBirthdayCalendars */
- private $backgroundJob;
+ private ITimeFactory&MockObject $time;
+ private IUserManager&MockObject $userManager;
+ private IJobList&MockObject $jobList;
+ private RegisterRegenerateBirthdayCalendars $backgroundJob;
protected function setUp(): void {
parent::setUp();
@@ -59,22 +53,26 @@ class RegisterRegenerateBirthdayCalendarsTest extends TestCase {
$closure($user3);
});
+ $calls = [
+ 'uid1',
+ 'uid2',
+ 'uid3',
+ ];
$this->jobList->expects($this->exactly(3))
->method('add')
- ->withConsecutive(
- [GenerateBirthdayCalendarBackgroundJob::class, [
- 'userId' => 'uid1',
- 'purgeBeforeGenerating' => true
- ]],
- [GenerateBirthdayCalendarBackgroundJob::class, [
- 'userId' => 'uid2',
- 'purgeBeforeGenerating' => true
- ]],
- [GenerateBirthdayCalendarBackgroundJob::class, [
- 'userId' => 'uid3',
- 'purgeBeforeGenerating' => true
- ]],
- );
+ ->willReturnCallback(function () use (&$calls): void {
+ $expected = array_shift($calls);
+ $this->assertEquals(
+ [
+ GenerateBirthdayCalendarBackgroundJob::class,
+ [
+ 'userId' => $expected,
+ 'purgeBeforeGenerating' => true
+ ]
+ ],
+ func_get_args()
+ );
+ });
$this->backgroundJob->run([]);
}
diff --git a/apps/dav/tests/unit/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJobTest.php b/apps/dav/tests/unit/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJobTest.php
index 18ee0c5c61d..38a981787cd 100644
--- a/apps/dav/tests/unit/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJobTest.php
+++ b/apps/dav/tests/unit/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJobTest.php
@@ -18,15 +18,9 @@ use Test\TestCase;
class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
private UpdateCalendarResourcesRoomsBackgroundJob $backgroundJob;
-
- /** @var ITimeFactory|MockObject */
- private $time;
-
- /** @var IResourceManager|MockObject */
- private $resourceManager;
-
- /** @var IRoomManager|MockObject */
- private $roomManager;
+ private ITimeFactory&MockObject $time;
+ private IResourceManager&MockObject $resourceManager;
+ private IRoomManager&MockObject $roomManager;
protected function setUp(): void {
parent::setUp();
diff --git a/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php b/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php
index ce3871aa400..369242ad488 100644
--- a/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php
+++ b/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php
@@ -29,14 +29,13 @@ use Test\TestCase;
* @group DB
*/
class UserStatusAutomationTest extends TestCase {
-
- protected MockObject|ITimeFactory $time;
- protected MockObject|IJobList $jobList;
- protected MockObject|LoggerInterface $logger;
- protected MockObject|IManager $statusManager;
- protected MockObject|IConfig $config;
- private IAvailabilityCoordinator|MockObject $coordinator;
- private IUserManager|MockObject $userManager;
+ protected ITimeFactory&MockObject $time;
+ protected IJobList&MockObject $jobList;
+ protected LoggerInterface&MockObject $logger;
+ protected IManager&MockObject $statusManager;
+ protected IConfig&MockObject $config;
+ private IAvailabilityCoordinator&MockObject $coordinator;
+ private IUserManager&MockObject $userManager;
protected function setUp(): void {
parent::setUp();
@@ -76,11 +75,11 @@ class UserStatusAutomationTest extends TestCase {
$this->coordinator,
$this->userManager,
])
- ->setMethods($methods)
+ ->onlyMethods($methods)
->getMock();
}
- public function dataRun(): array {
+ public static function dataRun(): array {
return [
['20230217', '2023-02-24 10:49:36.613834', true],
['20230224', '2023-02-24 10:49:36.613834', true],