Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ protected function setUp(): void {
}

/**
* @dataProvider sortDataProvider
* @param $data
*/
#[\PHPUnit\Framework\Attributes\DataProvider('sortDataProvider')]
public function testSort($data): void {
$commentMocks = [];
foreach ($data['actors'] as $actorType => $actors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function testViewInvalidComment(): void {
$this->commentsManager->expects($this->any())
->method('get')
->with('42')
->will($this->throwException(new NotFoundException()));
->willThrowException(new NotFoundException());

$this->rootFolder->expects($this->never())
->method('getUserFolder');
Expand Down
4 changes: 1 addition & 3 deletions apps/comments/tests/Unit/EventHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ public static function handledProvider(): array {
];
}

/**
* @dataProvider handledProvider
*/
#[\PHPUnit\Framework\Attributes\DataProvider('handledProvider')]
public function testHandled(string $eventType): void {
/** @var IComment|MockObject $comment */
$comment = $this->createMock(IComment::class);
Expand Down
6 changes: 2 additions & 4 deletions apps/comments/tests/Unit/Notification/ListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public static function eventProvider(): array {
}

/**
* @dataProvider eventProvider
* @param string $eventType
* @param string $notificationMethod
*/
#[\PHPUnit\Framework\Attributes\DataProvider('eventProvider')]
public function testEvaluate($eventType, $notificationMethod): void {
/** @var IComment|MockObject $comment */
$comment = $this->createMock(IComment::class);
Expand Down Expand Up @@ -110,9 +110,7 @@ public function testEvaluate($eventType, $notificationMethod): void {
$this->listener->evaluate($event);
}

/**
* @dataProvider eventProvider
*/
#[\PHPUnit\Framework\Attributes\DataProvider('eventProvider')]
public function testEvaluateNoMentions(string $eventType): void {
/** @var IComment|MockObject $comment */
$comment = $this->createMock(IComment::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function setUp(): void {
$this->output = $this->createMock(OutputInterface::class);
}

public function dataAssets(): array {
public static function dataAssets(): array {
return array_map(
function (string $filename) {
/** @var VCalendar $vCalendar */
Expand Down Expand Up @@ -89,9 +89,7 @@ private function getSanitizedComponents(VCalendar $vCalendar): array {
);
}

/**
* @dataProvider dataAssets
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataAssets')]
public function testImportExportAsset(string $userId, string $filename, string $initialCalendarUri, VCalendar $importCalendar): void {
$user = $this->userManager->createUser($userId, 'topsecretpassword');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function setUp(): void {
$this->output = $this->createMock(OutputInterface::class);
}

public function dataAssets(): array {
public static function dataAssets(): array {
return array_map(
function (string $filename) {
$vCardSplitter = new VCardSplitter(
Expand Down Expand Up @@ -91,11 +91,11 @@ private function getProperties(VCard $vCard): array {
}

/**
* @dataProvider dataAssets
*
* @param array{displayName: string, description?: string} $importMetadata
* @param VCard[] $importCards
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataAssets')]
public function testImportExportAsset(string $userId, string $filename, string $initialAddressBookUri, array $importMetadata, array $importCards): void {
$user = $this->userManager->createUser($userId, 'topsecretpassword');

Expand Down
12 changes: 3 additions & 9 deletions apps/dav/tests/unit/Avatars/AvatarHomeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ protected function setUp(): void {
$this->home = new AvatarHome(['uri' => 'principals/users/admin'], $this->avatarManager);
}

/**
* @dataProvider providesForbiddenMethods
*/
#[\PHPUnit\Framework\Attributes\DataProvider('providesForbiddenMethods')]
public function testForbiddenMethods($method): void {
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);

Expand Down Expand Up @@ -60,9 +58,7 @@ public static function providesTestGetChild(): array {
];
}

/**
* @dataProvider providesTestGetChild
*/
#[\PHPUnit\Framework\Attributes\DataProvider('providesTestGetChild')]
public function testGetChild(?string $expectedException, bool $hasAvatar, string $path): void {
if ($expectedException !== null) {
$this->expectException($expectedException);
Expand All @@ -87,9 +83,7 @@ public function testGetChildren(): void {
self::assertEquals(1, count($avatarNodes));
}

/**
* @dataProvider providesTestGetChild
*/
#[\PHPUnit\Framework\Attributes\DataProvider('providesTestGetChild')]
public function testChildExists(?string $expectedException, bool $hasAvatar, string $path): void {
$avatar = $this->createMock(IAvatar::class);
$avatar->method('exists')->willReturn($hasAvatar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ public static function data(): array {
}

/**
* @dataProvider data
*
* @param bool $sendEventReminders
* @param bool $sendEventRemindersMode
* @param bool $expectCall
*/
#[\PHPUnit\Framework\Attributes\DataProvider('data')]
public function testRun(bool $sendEventReminders, bool $sendEventRemindersMode, bool $expectCall): void {
$this->config->expects($this->exactly($sendEventReminders ? 2 : 1))
->method('getAppValue')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ protected function setUp(): void {
$this->backgroundJob = new PruneOutdatedSyncTokensJob($this->timeFactory, $this->calDavBackend, $this->cardDavBackend, $this->config, $this->logger);
}

/**
* @dataProvider dataForTestRun
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataForTestRun')]
public function testRun(string $configToKeep, string $configRetentionDays, int $actualLimit, int $retentionDays, int $deletedCalendarSyncTokens, int $deletedAddressBookSyncTokens): void {
$this->config->expects($this->exactly(2))
->method('getAppValue')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ protected function setUp(): void {
* @param int $lastRun
* @param int $time
* @param bool $process
*
* @dataProvider runDataProvider
*/
#[\PHPUnit\Framework\Attributes\DataProvider('runDataProvider')]
public function testRun(int $lastRun, int $time, bool $process): void {
$backgroundJob = new RefreshWebcalJob($this->refreshWebcalService, $this->config, $this->logger, $this->timeFactory);
$backgroundJob->setId(42);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ public static function dataRun(): array {
];
}

/**
* @dataProvider dataRun
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataRun')]
public function testRunNoOOO(string $ruleDay, string $currentTime, bool $isAvailable): void {
$user = $this->createConfiguredMock(IUser::class, [
'getUID' => 'user'
Expand Down
12 changes: 3 additions & 9 deletions apps/dav/tests/unit/CalDAV/Activity/BackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ public static function dataCallTriggerCalendarActivity(): array {
];
}

/**
* @dataProvider dataCallTriggerCalendarActivity
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataCallTriggerCalendarActivity')]
public function testCallTriggerCalendarActivity(string $method, array $payload, string $expectedSubject, array $expectedPayload): void {
$backend = $this->getBackend(['triggerCalendarActivity']);
$backend->expects($this->once())
Expand Down Expand Up @@ -168,9 +166,7 @@ public static function dataTriggerCalendarActivity(): array {
];
}

/**
* @dataProvider dataTriggerCalendarActivity
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataTriggerCalendarActivity')]
public function testTriggerCalendarActivity(string $action, array $data, array $shares, array $changedProperties, string $currentUser, string $author, ?array $shareUsers, array $users): void {
$backend = $this->getBackend(['getUsersForShares']);

Expand Down Expand Up @@ -299,9 +295,7 @@ public static function dataGetUsersForShares(): array {
];
}

/**
* @dataProvider dataGetUsersForShares
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataGetUsersForShares')]
public function testGetUsersForShares(array $shares, array $groups, array $expected): void {
$backend = $this->getBackend();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public static function dataFilterTypes(): array {
}

/**
* @dataProvider dataFilterTypes
* @param string[] $types
* @param string[] $expected
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataFilterTypes')]
public function testFilterTypes(array $types, array $expected): void {
$this->assertEquals($expected, $this->filter->filterTypes($types));
}
Expand Down
28 changes: 7 additions & 21 deletions apps/dav/tests/unit/CalDAV/Activity/Filter/GenericTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,27 @@ public static function dataFilters(): array {
];
}

/**
* @dataProvider dataFilters
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataFilters')]
public function testImplementsInterface(string $filterClass): void {
$filter = Server::get($filterClass);
$this->assertInstanceOf(IFilter::class, $filter);
}

/**
* @dataProvider dataFilters
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataFilters')]
public function testGetIdentifier(string $filterClass): void {
/** @var IFilter $filter */
$filter = Server::get($filterClass);
$this->assertIsString($filter->getIdentifier());
}

/**
* @dataProvider dataFilters
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataFilters')]
public function testGetName(string $filterClass): void {
/** @var IFilter $filter */
$filter = Server::get($filterClass);
$this->assertIsString($filter->getName());
}

/**
* @dataProvider dataFilters
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataFilters')]
public function testGetPriority(string $filterClass): void {
/** @var IFilter $filter */
$filter = Server::get($filterClass);
Expand All @@ -62,28 +54,22 @@ public function testGetPriority(string $filterClass): void {
$this->assertLessThanOrEqual(100, $priority);
}

/**
* @dataProvider dataFilters
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataFilters')]
public function testGetIcon(string $filterClass): void {
/** @var IFilter $filter */
$filter = Server::get($filterClass);
$this->assertIsString($filter->getIcon());
$this->assertStringStartsWith('http', $filter->getIcon());
}

/**
* @dataProvider dataFilters
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataFilters')]
public function testFilterTypes(string $filterClass): void {
/** @var IFilter $filter */
$filter = Server::get($filterClass);
$this->assertIsArray($filter->filterTypes([]));
}

/**
* @dataProvider dataFilters
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataFilters')]
public function testAllowedApps(string $filterClass): void {
/** @var IFilter $filter */
$filter = Server::get($filterClass);
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/tests/unit/CalDAV/Activity/Filter/TodoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public static function dataFilterTypes(): array {
}

/**
* @dataProvider dataFilterTypes
* @param string[] $types
* @param string[] $expected
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataFilterTypes')]
public function testFilterTypes(array $types, array $expected): void {
$this->assertEquals($expected, $this->filter->filterTypes($types));
}
Expand Down
16 changes: 4 additions & 12 deletions apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ public static function dataSetSubjects(): array {
];
}

/**
* @dataProvider dataSetSubjects
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataSetSubjects')]
public function testSetSubjects(string $subject, array $parameters): void {
$event = $this->createMock(IEvent::class);
$event->expects($this->once())
Expand All @@ -68,9 +66,7 @@ public static function dataGenerateCalendarParameter(): array {
];
}

/**
* @dataProvider dataGenerateCalendarParameter
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataGenerateCalendarParameter')]
public function testGenerateCalendarParameter(array $data, string $name): void {
$l = $this->createMock(IL10N::class);
$l->expects($this->any())
Expand All @@ -93,9 +89,7 @@ public static function dataGenerateLegacyCalendarParameter(): array {
];
}

/**
* @dataProvider dataGenerateLegacyCalendarParameter
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataGenerateLegacyCalendarParameter')]
public function testGenerateLegacyCalendarParameter(int $id, string $name): void {
$this->assertEquals([
'type' => 'calendar',
Expand All @@ -111,9 +105,7 @@ public static function dataGenerateGroupParameter(): array {
];
}

/**
* @dataProvider dataGenerateGroupParameter
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataGenerateGroupParameter')]
public function testGenerateGroupParameter(string $gid): void {
$this->assertEquals([
'type' => 'user-group',
Expand Down
12 changes: 3 additions & 9 deletions apps/dav/tests/unit/CalDAV/Activity/Provider/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ public static function dataGenerateObjectParameter(): array {
];
}

/**
* @dataProvider dataGenerateObjectParameter
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataGenerateObjectParameter')]
public function testGenerateObjectParameter(int $id, string $name, ?array $link, bool $calendarAppEnabled = true): void {
$affectedUser = 'otheruser';
if ($link) {
Expand Down Expand Up @@ -150,9 +148,7 @@ public static function generateObjectParameterLinkEncodingDataProvider(): array
];
}

/**
* @dataProvider generateObjectParameterLinkEncodingDataProvider
*/
#[\PHPUnit\Framework\Attributes\DataProvider('generateObjectParameterLinkEncodingDataProvider')]
public function testGenerateObjectParameterLinkEncoding(array $link, string $objectId): void {
$generatedLink = [
'objectId' => $objectId,
Expand Down Expand Up @@ -185,9 +181,7 @@ public static function dataGenerateObjectParameterThrows(): array {
];
}

/**
* @dataProvider dataGenerateObjectParameterThrows
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataGenerateObjectParameterThrows')]
public function testGenerateObjectParameterThrows(string|array $eventData, string $exception = InvalidArgumentException::class): void {
$this->expectException($exception);

Expand Down
Loading
Loading