diff options
author | Robin Appelman <robin@icewind.nl> | 2025-06-30 16:56:59 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2025-07-01 22:45:52 +0200 |
commit | aa15f9d16d5b46d04763c7deedb129990e819364 (patch) | |
tree | 758e0aebcac34a545f9a21806120a9fcb96f4cb6 /apps | |
parent | 1620a0c0510a42b1da0a66488838f1ce3ba1210d (diff) | |
download | nextcloud-server-rector-phpunit10.tar.gz nextcloud-server-rector-phpunit10.zip |
chore: run rectorrector-phpunit10
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps')
229 files changed, 612 insertions, 1359 deletions
diff --git a/apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php b/apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php index 79a2700e3d3..4d3392a562d 100644 --- a/apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php +++ b/apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php @@ -25,9 +25,9 @@ class CommentersSorterTest extends TestCase { } /** - * @dataProvider sortDataProvider * @param $data */ + #[\PHPUnit\Framework\Attributes\DataProvider('sortDataProvider')] public function testSort($data): void { $commentMocks = []; foreach ($data['actors'] as $actorType => $actors) { diff --git a/apps/comments/tests/Unit/Controller/NotificationsTest.php b/apps/comments/tests/Unit/Controller/NotificationsTest.php index 59d0b9ccb00..04490ca63e8 100644 --- a/apps/comments/tests/Unit/Controller/NotificationsTest.php +++ b/apps/comments/tests/Unit/Controller/NotificationsTest.php @@ -138,7 +138,7 @@ class NotificationsTest extends TestCase { $this->commentsManager->expects($this->any()) ->method('get') ->with('42') - ->will($this->throwException(new NotFoundException())); + ->willThrowException(new NotFoundException()); $this->rootFolder->expects($this->never()) ->method('getUserFolder'); diff --git a/apps/comments/tests/Unit/EventHandlerTest.php b/apps/comments/tests/Unit/EventHandlerTest.php index df2876e20a3..9d26f828d70 100644 --- a/apps/comments/tests/Unit/EventHandlerTest.php +++ b/apps/comments/tests/Unit/EventHandlerTest.php @@ -57,9 +57,7 @@ class EventHandlerTest extends TestCase { ]; } - /** - * @dataProvider handledProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('handledProvider')] public function testHandled(string $eventType): void { /** @var IComment|MockObject $comment */ $comment = $this->createMock(IComment::class); diff --git a/apps/comments/tests/Unit/Notification/ListenerTest.php b/apps/comments/tests/Unit/Notification/ListenerTest.php index ae5a3c40bc6..356a26f23cd 100644 --- a/apps/comments/tests/Unit/Notification/ListenerTest.php +++ b/apps/comments/tests/Unit/Notification/ListenerTest.php @@ -45,10 +45,10 @@ class ListenerTest extends TestCase { } /** - * @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); @@ -110,9 +110,7 @@ class ListenerTest extends TestCase { $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); diff --git a/apps/dav/tests/integration/UserMigration/CalendarMigratorTest.php b/apps/dav/tests/integration/UserMigration/CalendarMigratorTest.php index bb7f83e4d34..0682733a103 100644 --- a/apps/dav/tests/integration/UserMigration/CalendarMigratorTest.php +++ b/apps/dav/tests/integration/UserMigration/CalendarMigratorTest.php @@ -44,7 +44,7 @@ class CalendarMigratorTest extends TestCase { $this->output = $this->createMock(OutputInterface::class); } - public function dataAssets(): array { + public static function dataAssets(): array { return array_map( function (string $filename) { /** @var VCalendar $vCalendar */ @@ -89,9 +89,7 @@ class CalendarMigratorTest extends TestCase { ); } - /** - * @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'); diff --git a/apps/dav/tests/integration/UserMigration/ContactsMigratorTest.php b/apps/dav/tests/integration/UserMigration/ContactsMigratorTest.php index cb2a2d6c8b5..9ae1ca28501 100644 --- a/apps/dav/tests/integration/UserMigration/ContactsMigratorTest.php +++ b/apps/dav/tests/integration/UserMigration/ContactsMigratorTest.php @@ -44,7 +44,7 @@ class ContactsMigratorTest extends TestCase { $this->output = $this->createMock(OutputInterface::class); } - public function dataAssets(): array { + public static function dataAssets(): array { return array_map( function (string $filename) { $vCardSplitter = new VCardSplitter( @@ -91,11 +91,11 @@ class ContactsMigratorTest extends TestCase { } /** - * @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'); diff --git a/apps/dav/tests/unit/Avatars/AvatarHomeTest.php b/apps/dav/tests/unit/Avatars/AvatarHomeTest.php index aaa930b6c19..7117637a000 100644 --- a/apps/dav/tests/unit/Avatars/AvatarHomeTest.php +++ b/apps/dav/tests/unit/Avatars/AvatarHomeTest.php @@ -27,9 +27,7 @@ class AvatarHomeTest extends TestCase { $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); @@ -60,9 +58,7 @@ class AvatarHomeTest extends TestCase { ]; } - /** - * @dataProvider providesTestGetChild - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesTestGetChild')] public function testGetChild(?string $expectedException, bool $hasAvatar, string $path): void { if ($expectedException !== null) { $this->expectException($expectedException); @@ -87,9 +83,7 @@ class AvatarHomeTest extends TestCase { 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); diff --git a/apps/dav/tests/unit/BackgroundJob/EventReminderJobTest.php b/apps/dav/tests/unit/BackgroundJob/EventReminderJobTest.php index 1f70869f211..a46a1e5e5b0 100644 --- a/apps/dav/tests/unit/BackgroundJob/EventReminderJobTest.php +++ b/apps/dav/tests/unit/BackgroundJob/EventReminderJobTest.php @@ -45,12 +45,12 @@ class EventReminderJobTest extends TestCase { } /** - * @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') diff --git a/apps/dav/tests/unit/BackgroundJob/PruneOutdatedSyncTokensJobTest.php b/apps/dav/tests/unit/BackgroundJob/PruneOutdatedSyncTokensJobTest.php index eb471189c24..1838fb2537d 100644 --- a/apps/dav/tests/unit/BackgroundJob/PruneOutdatedSyncTokensJobTest.php +++ b/apps/dav/tests/unit/BackgroundJob/PruneOutdatedSyncTokensJobTest.php @@ -39,9 +39,7 @@ class PruneOutdatedSyncTokensJobTest extends TestCase { $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') diff --git a/apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php b/apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php index 0cdeb6436e2..7713ef2945a 100644 --- a/apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php +++ b/apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php @@ -41,9 +41,8 @@ class RefreshWebcalJobTest extends TestCase { * @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); diff --git a/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php b/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php index 369242ad488..d49d20180d9 100644 --- a/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php +++ b/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php @@ -88,9 +88,7 @@ class UserStatusAutomationTest extends TestCase { ]; } - /** - * @dataProvider dataRun - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataRun')] public function testRunNoOOO(string $ruleDay, string $currentTime, bool $isAvailable): void { $user = $this->createConfiguredMock(IUser::class, [ 'getUID' => 'user' diff --git a/apps/dav/tests/unit/CalDAV/Activity/BackendTest.php b/apps/dav/tests/unit/CalDAV/Activity/BackendTest.php index ebe989ad815..4848a01f6b9 100644 --- a/apps/dav/tests/unit/CalDAV/Activity/BackendTest.php +++ b/apps/dav/tests/unit/CalDAV/Activity/BackendTest.php @@ -71,9 +71,7 @@ class BackendTest extends TestCase { ]; } - /** - * @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()) @@ -168,9 +166,7 @@ class BackendTest extends TestCase { ]; } - /** - * @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']); @@ -299,9 +295,7 @@ class BackendTest extends TestCase { ]; } - /** - * @dataProvider dataGetUsersForShares - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetUsersForShares')] public function testGetUsersForShares(array $shares, array $groups, array $expected): void { $backend = $this->getBackend(); diff --git a/apps/dav/tests/unit/CalDAV/Activity/Filter/CalendarTest.php b/apps/dav/tests/unit/CalDAV/Activity/Filter/CalendarTest.php index a31907b4b0a..b4c4e14fe7d 100644 --- a/apps/dav/tests/unit/CalDAV/Activity/Filter/CalendarTest.php +++ b/apps/dav/tests/unit/CalDAV/Activity/Filter/CalendarTest.php @@ -57,10 +57,10 @@ class CalendarTest extends TestCase { } /** - * @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)); } diff --git a/apps/dav/tests/unit/CalDAV/Activity/Filter/GenericTest.php b/apps/dav/tests/unit/CalDAV/Activity/Filter/GenericTest.php index 468dd15f480..87b55f14bcc 100644 --- a/apps/dav/tests/unit/CalDAV/Activity/Filter/GenericTest.php +++ b/apps/dav/tests/unit/CalDAV/Activity/Filter/GenericTest.php @@ -24,35 +24,27 @@ class GenericTest extends TestCase { ]; } - /** - * @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); @@ -62,9 +54,7 @@ class GenericTest extends TestCase { $this->assertLessThanOrEqual(100, $priority); } - /** - * @dataProvider dataFilters - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataFilters')] public function testGetIcon(string $filterClass): void { /** @var IFilter $filter */ $filter = Server::get($filterClass); @@ -72,18 +62,14 @@ class GenericTest extends TestCase { $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); diff --git a/apps/dav/tests/unit/CalDAV/Activity/Filter/TodoTest.php b/apps/dav/tests/unit/CalDAV/Activity/Filter/TodoTest.php index 6ef7289e156..f18d66b9774 100644 --- a/apps/dav/tests/unit/CalDAV/Activity/Filter/TodoTest.php +++ b/apps/dav/tests/unit/CalDAV/Activity/Filter/TodoTest.php @@ -57,10 +57,10 @@ class TodoTest extends TestCase { } /** - * @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)); } diff --git a/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php b/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php index 113af7ed240..3e6219beef8 100644 --- a/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php +++ b/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php @@ -44,9 +44,7 @@ class BaseTest extends TestCase { ]; } - /** - * @dataProvider dataSetSubjects - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSetSubjects')] public function testSetSubjects(string $subject, array $parameters): void { $event = $this->createMock(IEvent::class); $event->expects($this->once()) @@ -68,9 +66,7 @@ class BaseTest extends TestCase { ]; } - /** - * @dataProvider dataGenerateCalendarParameter - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGenerateCalendarParameter')] public function testGenerateCalendarParameter(array $data, string $name): void { $l = $this->createMock(IL10N::class); $l->expects($this->any()) @@ -93,9 +89,7 @@ class BaseTest extends TestCase { ]; } - /** - * @dataProvider dataGenerateLegacyCalendarParameter - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGenerateLegacyCalendarParameter')] public function testGenerateLegacyCalendarParameter(int $id, string $name): void { $this->assertEquals([ 'type' => 'calendar', @@ -111,9 +105,7 @@ class BaseTest extends TestCase { ]; } - /** - * @dataProvider dataGenerateGroupParameter - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGenerateGroupParameter')] public function testGenerateGroupParameter(string $gid): void { $this->assertEquals([ 'type' => 'user-group', diff --git a/apps/dav/tests/unit/CalDAV/Activity/Provider/EventTest.php b/apps/dav/tests/unit/CalDAV/Activity/Provider/EventTest.php index 52d3dfa64cb..4fd38c1aed2 100644 --- a/apps/dav/tests/unit/CalDAV/Activity/Provider/EventTest.php +++ b/apps/dav/tests/unit/CalDAV/Activity/Provider/EventTest.php @@ -67,9 +67,7 @@ class EventTest extends TestCase { ]; } - /** - * @dataProvider dataGenerateObjectParameter - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGenerateObjectParameter')] public function testGenerateObjectParameter(int $id, string $name, ?array $link, bool $calendarAppEnabled = true): void { $affectedUser = 'otheruser'; if ($link) { @@ -150,9 +148,7 @@ class EventTest extends TestCase { ]; } - /** - * @dataProvider generateObjectParameterLinkEncodingDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('generateObjectParameterLinkEncodingDataProvider')] public function testGenerateObjectParameterLinkEncoding(array $link, string $objectId): void { $generatedLink = [ 'objectId' => $objectId, @@ -185,9 +181,7 @@ class EventTest extends TestCase { ]; } - /** - * @dataProvider dataGenerateObjectParameterThrows - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGenerateObjectParameterThrows')] public function testGenerateObjectParameterThrows(string|array $eventData, string $exception = InvalidArgumentException::class): void { $this->expectException($exception); diff --git a/apps/dav/tests/unit/CalDAV/Activity/Setting/GenericTest.php b/apps/dav/tests/unit/CalDAV/Activity/Setting/GenericTest.php index 2ed3bab02e6..23126b6bbcf 100644 --- a/apps/dav/tests/unit/CalDAV/Activity/Setting/GenericTest.php +++ b/apps/dav/tests/unit/CalDAV/Activity/Setting/GenericTest.php @@ -23,35 +23,27 @@ class GenericTest extends TestCase { ]; } - /** - * @dataProvider dataSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] public function testImplementsInterface(string $settingClass): void { $setting = Server::get($settingClass); $this->assertInstanceOf(ISetting::class, $setting); } - /** - * @dataProvider dataSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] public function testGetIdentifier(string $settingClass): void { /** @var ISetting $setting */ $setting = Server::get($settingClass); $this->assertIsString($setting->getIdentifier()); } - /** - * @dataProvider dataSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] public function testGetName(string $settingClass): void { /** @var ISetting $setting */ $setting = Server::get($settingClass); $this->assertIsString($setting->getName()); } - /** - * @dataProvider dataSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] public function testGetPriority(string $settingClass): void { /** @var ISetting $setting */ $setting = Server::get($settingClass); @@ -61,36 +53,28 @@ class GenericTest extends TestCase { $this->assertLessThanOrEqual(100, $priority); } - /** - * @dataProvider dataSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] public function testCanChangeStream(string $settingClass): void { /** @var ISetting $setting */ $setting = Server::get($settingClass); $this->assertIsBool($setting->canChangeStream()); } - /** - * @dataProvider dataSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] public function testIsDefaultEnabledStream(string $settingClass): void { /** @var ISetting $setting */ $setting = Server::get($settingClass); $this->assertIsBool($setting->isDefaultEnabledStream()); } - /** - * @dataProvider dataSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] public function testCanChangeMail(string $settingClass): void { /** @var ISetting $setting */ $setting = Server::get($settingClass); $this->assertIsBool($setting->canChangeMail()); } - /** - * @dataProvider dataSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] public function testIsDefaultEnabledMail(string $settingClass): void { /** @var ISetting $setting */ $setting = Server::get($settingClass); diff --git a/apps/dav/tests/unit/CalDAV/AppCalendar/AppCalendarTest.php b/apps/dav/tests/unit/CalDAV/AppCalendar/AppCalendarTest.php index bac2094f734..84879e87238 100644 --- a/apps/dav/tests/unit/CalDAV/AppCalendar/AppCalendarTest.php +++ b/apps/dav/tests/unit/CalDAV/AppCalendar/AppCalendarTest.php @@ -61,7 +61,7 @@ class AppCalendarTest extends TestCase { ]; $this->writeableCalendar->expects($this->exactly(3)) ->method('createFromString') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php index f8368660626..f9205d5d322 100644 --- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php @@ -112,9 +112,7 @@ class CalDavBackendTest extends AbstractCalDavBackend { ]; } - /** - * @dataProvider providesSharingData - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesSharingData')] public function testCalendarSharing($userCanRead, $userCanWrite, $groupCanRead, $groupCanWrite, $add, $principals): void { $logger = $this->createMock(\Psr\Log\LoggerInterface::class); $config = $this->createMock(IConfig::class); @@ -403,9 +401,7 @@ EOD; $this->assertCount(0, $calendarObjects); } - /** - * @dataProvider providesCalendarQueryParameters - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesCalendarQueryParameters')] public function testCalendarQuery($expectedEventsInResult, $propFilters, $compFilter): void { $calendarId = $this->createTestCalendar(); $events = []; @@ -692,9 +688,9 @@ EOS; } /** - * @dataProvider providesSchedulingData * @param $objectData */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesSchedulingData')] public function testScheduling($objectData): void { $this->backend->createSchedulingObject(self::UNIT_TEST_USER, 'Sample Schedule', $objectData); @@ -710,9 +706,7 @@ EOS; $this->assertCount(0, $sos); } - /** - * @dataProvider providesCalDataForGetDenormalizedData - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesCalDataForGetDenormalizedData')] public function testGetDenormalizedData($expected, $key, $calData): void { try { $actual = $this->backend->getDenormalizedData($calData); @@ -878,9 +872,7 @@ EOD; $this->assertEquals(count($search5), 0); } - /** - * @dataProvider searchDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('searchDataProvider')] public function testSearch(bool $isShared, array $searchOptions, int $count): void { $calendarId = $this->createTestCalendar(); diff --git a/apps/dav/tests/unit/CalDAV/CalendarTest.php b/apps/dav/tests/unit/CalDAV/CalendarTest.php index 0eff72c5c3d..b0d3c35bfe7 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarTest.php @@ -144,9 +144,7 @@ class CalendarTest extends TestCase { ]; } - /** - * @dataProvider dataPropPatch - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataPropPatch')] public function testPropPatch(string $ownerPrincipal, string $principalUri, array $mutations, bool $shared): void { /** @var CalDavBackend&MockObject $backend */ $backend = $this->createMock(CalDavBackend::class); @@ -168,9 +166,7 @@ class CalendarTest extends TestCase { $this->addToAssertionCount(1); } - /** - * @dataProvider providesReadOnlyInfo - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesReadOnlyInfo')] public function testAcl($expectsWrite, $readOnlyValue, $hasOwnerSet, $uri = 'default'): void { /** @var CalDavBackend&MockObject $backend */ $backend = $this->createMock(CalDavBackend::class); @@ -270,9 +266,7 @@ class CalendarTest extends TestCase { ]; } - /** - * @dataProvider providesConfidentialClassificationData - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesConfidentialClassificationData')] public function testPrivateClassification(int $expectedChildren, bool $isShared): void { $calObject0 = ['uri' => 'event-0', 'classification' => CalDavBackend::CLASSIFICATION_PUBLIC]; $calObject1 = ['uri' => 'event-1', 'classification' => CalDavBackend::CLASSIFICATION_CONFIDENTIAL]; @@ -310,9 +304,7 @@ class CalendarTest extends TestCase { $this->assertEquals(!$isShared, $c->childExists('event-2')); } - /** - * @dataProvider providesConfidentialClassificationData - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesConfidentialClassificationData')] public function testConfidentialClassification(int $expectedChildren, bool $isShared): void { $start = '20160609'; $end = '20160610'; diff --git a/apps/dav/tests/unit/CalDAV/Integration/ExternalCalendarTest.php b/apps/dav/tests/unit/CalDAV/Integration/ExternalCalendarTest.php index 5bf247719f7..b2f479ac0e3 100644 --- a/apps/dav/tests/unit/CalDAV/Integration/ExternalCalendarTest.php +++ b/apps/dav/tests/unit/CalDAV/Integration/ExternalCalendarTest.php @@ -66,9 +66,7 @@ class ExternalCalendarTest extends TestCase { $this->assertTrue(ExternalCalendar::isAppGeneratedCalendar('app-generated--example--foo--2')); } - /** - * @dataProvider splitAppGeneratedCalendarUriDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('splitAppGeneratedCalendarUriDataProvider')] public function testSplitAppGeneratedCalendarUriInvalid(string $name):void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Provided calendar uri was not app-generated'); diff --git a/apps/dav/tests/unit/CalDAV/PluginTest.php b/apps/dav/tests/unit/CalDAV/PluginTest.php index 647e4b0da81..c5725a1fa81 100644 --- a/apps/dav/tests/unit/CalDAV/PluginTest.php +++ b/apps/dav/tests/unit/CalDAV/PluginTest.php @@ -36,9 +36,7 @@ class PluginTest extends TestCase { ]; } - /** - * @dataProvider linkProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('linkProvider')] public function testGetCalendarHomeForPrincipal(string $input, string $expected): void { $this->assertSame($expected, $this->plugin->getCalendarHomeForPrincipal($input)); } diff --git a/apps/dav/tests/unit/CalDAV/PublicCalendarTest.php b/apps/dav/tests/unit/CalDAV/PublicCalendarTest.php index 7e8f714ef42..98153a067fb 100644 --- a/apps/dav/tests/unit/CalDAV/PublicCalendarTest.php +++ b/apps/dav/tests/unit/CalDAV/PublicCalendarTest.php @@ -16,9 +16,7 @@ use Sabre\VObject\Reader; class PublicCalendarTest extends CalendarTest { - /** - * @dataProvider providesConfidentialClassificationData - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesConfidentialClassificationData')] public function testPrivateClassification(int $expectedChildren, bool $isShared): void { $calObject0 = ['uri' => 'event-0', 'classification' => CalDavBackend::CLASSIFICATION_PUBLIC]; $calObject1 = ['uri' => 'event-1', 'classification' => CalDavBackend::CLASSIFICATION_CONFIDENTIAL]; @@ -57,9 +55,7 @@ class PublicCalendarTest extends CalendarTest { $this->assertFalse($c->childExists('event-2')); } - /** - * @dataProvider providesConfidentialClassificationData - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesConfidentialClassificationData')] public function testConfidentialClassification(int $expectedChildren, bool $isShared): void { $start = '20160609'; $end = '20160610'; diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php index c601463363b..5034af49cae 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php @@ -107,7 +107,7 @@ class PushProviderTest extends AbstractNotificationProviderTestCase { ]; $this->manager->expects($this->exactly(3)) ->method('notify') - ->willReturnCallback(function ($notification) use (&$calls) { + ->willReturnCallback(function ($notification) use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, $notification); }); diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php index 147446152d8..c091f590711 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php @@ -170,9 +170,7 @@ class NotifierTest extends TestCase { ]; } - /** - * @dataProvider dataPrepare - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataPrepare')] public function testPrepare(string $subjectType, array $subjectParams, string $subject, array $messageParams, string $message): void { /** @var INotification&MockObject $notification */ $notification = $this->createMock(INotification::class); diff --git a/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php b/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php index 4b6735ee297..c18901c5f58 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php @@ -747,7 +747,7 @@ EOD; ]; $this->backend->expects($this->exactly(5)) ->method('removeReminder') - ->willReturnCallback(function () use (&$removeReminderCalls) { + ->willReturnCallback(function () use (&$removeReminderCalls): void { $expected = array_shift($removeReminderCalls); $this->assertEquals($expected, func_get_args()); }); diff --git a/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTestCase.php b/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTestCase.php index 26dbcc0f38c..364bc74de49 100644 --- a/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTestCase.php +++ b/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTestCase.php @@ -246,9 +246,7 @@ abstract class AbstractPrincipalBackendTestCase extends TestCase { $this->assertEquals(0, $actual); } - /** - * @dataProvider dataSearchPrincipals - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSearchPrincipals')] public function testSearchPrincipals($expected, $test): void { $user = $this->createMock(IUser::class); $this->userSession->expects($this->once()) diff --git a/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php index 5dadb753a79..524ac556e19 100644 --- a/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php @@ -74,7 +74,7 @@ class PluginTest extends TestCase { ]; $this->server->expects($this->exactly(count($calls))) ->method('on') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); @@ -251,9 +251,7 @@ class PluginTest extends TestCase { ]; } - /** - * @dataProvider propFindDefaultCalendarUrlProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('propFindDefaultCalendarUrlProvider')] public function testPropFindDefaultCalendarUrl(string $principalUri, ?string $calendarHome, bool $isResource, string $calendarUri, string $displayName, bool $exists, bool $deleted = false, bool $hasExistingCalendars = false, bool $propertiesForPath = true): void { $propFind = new PropFind( $principalUri, diff --git a/apps/dav/tests/unit/CalDAV/WebcalCaching/ConnectionTest.php b/apps/dav/tests/unit/CalDAV/WebcalCaching/ConnectionTest.php index 35afc4d7ca7..c29415ecef3 100644 --- a/apps/dav/tests/unit/CalDAV/WebcalCaching/ConnectionTest.php +++ b/apps/dav/tests/unit/CalDAV/WebcalCaching/ConnectionTest.php @@ -32,9 +32,7 @@ class ConnectionTest extends TestCase { $this->connection = new Connection($this->clientService, $this->config, $this->logger); } - /** - * @dataProvider runLocalURLDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('runLocalURLDataProvider')] public function testLocalUrl($source): void { $subscription = [ 'id' => 42, @@ -94,8 +92,8 @@ class ConnectionTest extends TestCase { /** * @param string $result * @param string $contentType - * @dataProvider urlDataProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('urlDataProvider')] public function testConnection(string $url, string $result, string $contentType): void { $client = $this->createMock(IClient::class); $response = $this->createMock(IResponse::class); diff --git a/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php b/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php index 3252322ccff..d4f4b9e878f 100644 --- a/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php +++ b/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php @@ -34,9 +34,7 @@ class RefreshWebcalServiceTest extends TestCase { $this->time = $this->createMock(ITimeFactory::class); } - /** - * @dataProvider runDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('runDataProvider')] public function testRun(string $body, string $contentType, string $result): void { $refreshWebcalService = $this->getMockBuilder(RefreshWebcalService::class) ->onlyMethods(['getRandomCalendarObjectUri']) @@ -83,9 +81,7 @@ class RefreshWebcalServiceTest extends TestCase { $refreshWebcalService->refreshSubscription('principals/users/testuser', 'sub123'); } - /** - * @dataProvider identicalDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('identicalDataProvider')] public function testRunIdentical(string $uid, array $calendarObject, string $body, string $contentType, string $result): void { $refreshWebcalService = $this->getMockBuilder(RefreshWebcalService::class) ->onlyMethods(['getRandomCalendarObjectUri']) @@ -200,9 +196,7 @@ class RefreshWebcalServiceTest extends TestCase { $refreshWebcalService->refreshSubscription('principals/users/testuser', 'sub123'); } - /** - * @dataProvider runDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('runDataProvider')] public function testRunCreateCalendarNoException(string $body, string $contentType, string $result): void { $refreshWebcalService = $this->getMockBuilder(RefreshWebcalService::class) ->onlyMethods(['getRandomCalendarObjectUri', 'getSubscription',]) @@ -246,9 +240,7 @@ class RefreshWebcalServiceTest extends TestCase { $refreshWebcalService->refreshSubscription('principals/users/testuser', 'sub123'); } - /** - * @dataProvider runDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('runDataProvider')] public function testRunCreateCalendarBadRequest(string $body, string $contentType, string $result): void { $refreshWebcalService = $this->getMockBuilder(RefreshWebcalService::class) ->onlyMethods(['getRandomCalendarObjectUri', 'getSubscription']) diff --git a/apps/dav/tests/unit/CardDAV/Activity/BackendTest.php b/apps/dav/tests/unit/CardDAV/Activity/BackendTest.php index 4de1cf25cc5..a070a3d7131 100644 --- a/apps/dav/tests/unit/CardDAV/Activity/BackendTest.php +++ b/apps/dav/tests/unit/CardDAV/Activity/BackendTest.php @@ -71,9 +71,7 @@ class BackendTest extends TestCase { ]; } - /** - * @dataProvider dataCallTriggerAddressBookActivity - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataCallTriggerAddressBookActivity')] public function testCallTriggerAddressBookActivity(string $method, array $payload, string $expectedSubject, array $expectedPayload): void { $backend = $this->getBackend(['triggerAddressbookActivity']); $backend->expects($this->once()) @@ -151,10 +149,10 @@ class BackendTest extends TestCase { } /** - * @dataProvider dataTriggerAddressBookActivity * @param string[]|null $shareUsers * @param string[] $users */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTriggerAddressBookActivity')] public function testTriggerAddressBookActivity(string $action, array $data, array $shares, array $changedProperties, string $currentUser, string $author, ?array $shareUsers, array $users): void { $backend = $this->getBackend(['getUsersForShares']); @@ -315,10 +313,10 @@ class BackendTest extends TestCase { } /** - * @dataProvider dataTriggerCardActivity * @param string[]|null $shareUsers * @param string[] $users */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTriggerCardActivity')] public function testTriggerCardActivity(string $action, array $addressBookData, array $shares, array $cardData, string $currentUser, string $author, ?array $shareUsers, array $users): void { $backend = $this->getBackend(['getUsersForShares']); @@ -432,9 +430,7 @@ class BackendTest extends TestCase { ]; } - /** - * @dataProvider dataGetUsersForShares - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetUsersForShares')] public function testGetUsersForShares(array $shares, array $groups, array $expected): void { $backend = $this->getBackend(); diff --git a/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php b/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php index cfb14a5d567..f7daeb41cca 100644 --- a/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php +++ b/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php @@ -103,9 +103,7 @@ class AddressBookImplTest extends TestCase { $this->assertSame(2, count($result)); } - /** - * @dataProvider dataTestCreate - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestCreate')] public function testCreate(array $properties): void { $uid = 'uid'; @@ -230,9 +228,7 @@ class AddressBookImplTest extends TestCase { $addressBookImpl->createOrUpdate($properties); } - /** - * @dataProvider dataTestGetPermissions - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetPermissions')] public function testGetPermissions(array $permissions, int $expected): void { $this->addressBook->expects($this->once())->method('getACL') ->willReturn($permissions); diff --git a/apps/dav/tests/unit/CardDAV/AddressBookTest.php b/apps/dav/tests/unit/CardDAV/AddressBookTest.php index 043b192e2c8..85ccb016946 100644 --- a/apps/dav/tests/unit/CardDAV/AddressBookTest.php +++ b/apps/dav/tests/unit/CardDAV/AddressBookTest.php @@ -117,9 +117,7 @@ class AddressBookTest extends TestCase { $addressBook->propPatch(new PropPatch(['{DAV:}displayname' => 'Test address book'])); } - /** - * @dataProvider providesReadOnlyInfo - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesReadOnlyInfo')] public function testAcl(bool $expectsWrite, ?bool $readOnlyValue, bool $hasOwnerSet): void { /** @var MockObject | CardDavBackend $backend */ $backend = $this->createMock(CardDavBackend::class); diff --git a/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php b/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php index 5a1210da339..6908dfd17bc 100644 --- a/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php +++ b/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php @@ -50,9 +50,7 @@ class BirthdayServiceTest extends TestCase { $this->dbConnection, $this->l10n); } - /** - * @dataProvider providesVCards - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesVCards')] public function testBuildBirthdayFromContact(?string $expectedSummary, ?string $expectedDTStart, ?string $expectedRrule, ?string $expectedFieldType, ?string $expectedUnknownYear, ?string $expectedOriginalYear, ?string $expectedReminder, ?string $data, string $fieldType, string $prefix, bool $supports4Bytes, ?string $configuredReminder): void { $this->dbConnection->method('supports4ByteText')->willReturn($supports4Bytes); $cal = $this->service->buildDateFromContact($data, $fieldType, $prefix, $configuredReminder); @@ -146,7 +144,7 @@ class BirthdayServiceTest extends TestCase { ]; $this->calDav->expects($this->exactly(count($calls))) ->method('deleteCalendarObject') - ->willReturnCallback(function ($calendarId, $objectUri) use (&$calls) { + ->willReturnCallback(function ($calendarId, $objectUri) use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, [$calendarId, $objectUri]); }); @@ -200,9 +198,7 @@ class BirthdayServiceTest extends TestCase { $service->onCardChanged(666, 'gump.vcf', ''); } - /** - * @dataProvider providesCardChanges - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesCardChanges')] public function testOnCardChanged(string $expectedOp): void { $this->config->expects($this->once()) ->method('getAppValue') @@ -246,7 +242,7 @@ class BirthdayServiceTest extends TestCase { ]; $this->calDav->expects($this->exactly(count($calls))) ->method('deleteCalendarObject') - ->willReturnCallback(function ($calendarId, $objectUri) use (&$calls) { + ->willReturnCallback(function ($calendarId, $objectUri) use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, [$calendarId, $objectUri]); }); @@ -264,7 +260,7 @@ class BirthdayServiceTest extends TestCase { ]; $this->calDav->expects($this->exactly(count($createCalendarObjectCalls))) ->method('createCalendarObject') - ->willReturnCallback(function ($calendarId, $objectUri, $calendarData) use (&$createCalendarObjectCalls) { + ->willReturnCallback(function ($calendarId, $objectUri, $calendarData) use (&$createCalendarObjectCalls): void { $expected = array_shift($createCalendarObjectCalls); $this->assertEquals($expected, [$calendarId, $objectUri, $calendarData]); }); @@ -284,7 +280,7 @@ class BirthdayServiceTest extends TestCase { ]; $this->calDav->expects($this->exactly(count($updateCalendarObjectCalls))) ->method('updateCalendarObject') - ->willReturnCallback(function ($calendarId, $objectUri, $calendarData) use (&$updateCalendarObjectCalls) { + ->willReturnCallback(function ($calendarId, $objectUri, $calendarData) use (&$updateCalendarObjectCalls): void { $expected = array_shift($updateCalendarObjectCalls); $this->assertEquals($expected, [$calendarId, $objectUri, $calendarData]); }); @@ -293,9 +289,7 @@ class BirthdayServiceTest extends TestCase { $service->onCardChanged(666, 'gump.vcf', ''); } - /** - * @dataProvider providesBirthday - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesBirthday')] public function testBirthdayEvenChanged(bool $expected, string $old, string $new): void { $new = Reader::read($new); $this->assertEquals($expected, $this->service->birthdayEvenChanged($old, $new)); @@ -369,7 +363,7 @@ class BirthdayServiceTest extends TestCase { ]; $this->calDav->expects($this->exactly(count($calls))) ->method('deleteCalendarObject') - ->willReturnCallback(function ($calendarId, $objectUri, $calendarType) use (&$calls) { + ->willReturnCallback(function ($calendarId, $objectUri, $calendarType) use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, [$calendarId, $objectUri, $calendarType]); }); diff --git a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php index 735f664a2bb..1966a8d8c9a 100644 --- a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php +++ b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php @@ -249,7 +249,7 @@ class CardDavBackendTest extends TestCase { ]; $backend->expects($this->exactly(count($calls))) ->method('updateProperties') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); @@ -437,7 +437,7 @@ class CardDavBackendTest extends TestCase { ]; $this->backend->expects($this->exactly(count($calls))) ->method('addChange') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); @@ -645,9 +645,7 @@ class CardDavBackendTest extends TestCase { $this->invokePrivate($this->backend, 'getCardId', [1, 'uri']); } - /** - * @dataProvider dataTestSearch - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSearch')] public function testSearch(string $pattern, array $properties, array $options, array $expected): void { /** @var VCard $vCards */ $vCards = []; diff --git a/apps/dav/tests/unit/CardDAV/ConverterTest.php b/apps/dav/tests/unit/CardDAV/ConverterTest.php index 59042ed91d4..00519b82766 100644 --- a/apps/dav/tests/unit/CardDAV/ConverterTest.php +++ b/apps/dav/tests/unit/CardDAV/ConverterTest.php @@ -79,9 +79,7 @@ class ConverterTest extends TestCase { return $accountManager; } - /** - * @dataProvider providesNewUsers - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesNewUsers')] public function testCreation($expectedVCard, $displayName = null, $eMailAddress = null, $cloudId = null): void { $user = $this->getUserMock((string)$displayName, $eMailAddress, $cloudId); $accountManager = $this->getAccountManager($user); @@ -189,9 +187,7 @@ class ConverterTest extends TestCase { ]; } - /** - * @dataProvider providesNames - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesNames')] public function testNameSplitter(string $expected, string $fullName): void { $converter = new Converter($this->accountManager, $this->userManager, $this->urlGenerator, $this->logger); $r = $converter->splitFullName($fullName); diff --git a/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php b/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php index 8396234a819..d47f53bddcd 100644 --- a/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php +++ b/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php @@ -45,9 +45,7 @@ class ImageExportPluginTest extends TestCase { $this->plugin->initialize($this->server); } - /** - * @dataProvider providesQueryParams - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesQueryParams')] public function testQueryParams(array $param): void { $this->request->expects($this->once())->method('getQueryParameters')->willReturn($param); $result = $this->plugin->httpGet($this->request, $this->response); @@ -88,9 +86,7 @@ class ImageExportPluginTest extends TestCase { ]; } - /** - * @dataProvider dataTestCard - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestCard')] public function testCard(?int $size, bool $photo): void { $query = ['photo' => null]; if ($size !== null) { @@ -142,7 +138,7 @@ class ImageExportPluginTest extends TestCase { ]; $this->response->expects($this->exactly(count($setHeaderCalls))) ->method('setHeader') - ->willReturnCallback(function () use (&$setHeaderCalls) { + ->willReturnCallback(function () use (&$setHeaderCalls): void { $expected = array_shift($setHeaderCalls); $this->assertEquals($expected, func_get_args()); }); @@ -160,7 +156,7 @@ class ImageExportPluginTest extends TestCase { ]; $this->response->expects($this->exactly(count($setHeaderCalls))) ->method('setHeader') - ->willReturnCallback(function () use (&$setHeaderCalls) { + ->willReturnCallback(function () use (&$setHeaderCalls): void { $expected = array_shift($setHeaderCalls); $this->assertEquals($expected, func_get_args()); }); diff --git a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php index fd31ef36528..ea4886a67e6 100644 --- a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php +++ b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php @@ -325,9 +325,7 @@ END:VCARD'; ]; } - /** - * @dataProvider dataActivatedUsers - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataActivatedUsers')] public function testUpdateAndDeleteUser(bool $activated, int $createCalls, int $updateCalls, int $deleteCalls): void { /** @var CardDavBackend | MockObject $backend */ $backend = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock(); @@ -427,9 +425,7 @@ END:VCARD'; ); } - /** - * @dataProvider providerUseAbsoluteUriReport - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providerUseAbsoluteUriReport')] public function testUseAbsoluteUriReport(string $host, string $expected): void { $body = '<?xml version="1.0"?> <d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:oc="http://owncloud.org/ns"> diff --git a/apps/dav/tests/unit/Command/ListAddressbooksTest.php b/apps/dav/tests/unit/Command/ListAddressbooksTest.php index 624b0050bc5..2768ed576c3 100644 --- a/apps/dav/tests/unit/Command/ListAddressbooksTest.php +++ b/apps/dav/tests/unit/Command/ListAddressbooksTest.php @@ -78,9 +78,7 @@ class ListAddressbooksTest extends TestCase { ]; } - /** - * @dataProvider dataExecute - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataExecute')] public function testWithCorrectUser(bool $readOnly, string $output): void { $this->userManager->expects($this->once()) ->method('userExists') diff --git a/apps/dav/tests/unit/Command/ListCalendarsTest.php b/apps/dav/tests/unit/Command/ListCalendarsTest.php index 247487433eb..d398a7c772f 100644 --- a/apps/dav/tests/unit/Command/ListCalendarsTest.php +++ b/apps/dav/tests/unit/Command/ListCalendarsTest.php @@ -79,9 +79,7 @@ class ListCalendarsTest extends TestCase { ]; } - /** - * @dataProvider dataExecute - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataExecute')] public function testWithCorrectUser(bool $readOnly, string $output): void { $this->userManager->expects($this->once()) ->method('userExists') diff --git a/apps/dav/tests/unit/Command/MoveCalendarTest.php b/apps/dav/tests/unit/Command/MoveCalendarTest.php index c481f5cf15b..e9f016961f2 100644 --- a/apps/dav/tests/unit/Command/MoveCalendarTest.php +++ b/apps/dav/tests/unit/Command/MoveCalendarTest.php @@ -64,9 +64,7 @@ class MoveCalendarTest extends TestCase { ]; } - /** - * @dataProvider dataExecute - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataExecute')] public function testWithBadUserOrigin(bool $userOriginExists, bool $userDestinationExists): void { $this->expectException(\InvalidArgumentException::class); @@ -178,9 +176,7 @@ class MoveCalendarTest extends TestCase { ]; } - /** - * @dataProvider dataTestMoveWithDestinationNotPartOfGroup - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestMoveWithDestinationNotPartOfGroup')] public function testMoveWithDestinationNotPartOfGroup(bool $shareWithGroupMembersOnly): void { $this->userManager->expects($this->exactly(2)) ->method('userExists') @@ -311,9 +307,7 @@ class MoveCalendarTest extends TestCase { ]; } - /** - * @dataProvider dataTestMoveWithCalendarAlreadySharedToDestination - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestMoveWithCalendarAlreadySharedToDestination')] public function testMoveWithCalendarAlreadySharedToDestination(bool $force): void { $this->userManager->expects($this->exactly(2)) ->method('userExists') diff --git a/apps/dav/tests/unit/Comments/CommentsNodeTest.php b/apps/dav/tests/unit/Comments/CommentsNodeTest.php index 40da2e523c7..9e108b4cf63 100644 --- a/apps/dav/tests/unit/Comments/CommentsNodeTest.php +++ b/apps/dav/tests/unit/Comments/CommentsNodeTest.php @@ -174,7 +174,7 @@ class CommentsNodeTest extends \Test\TestCase { $this->comment->expects($this->once()) ->method('setMessage') ->with($msg) - ->will($this->throwException(new \Exception('buh!'))); + ->willThrowException(new \Exception('buh!')); $this->comment->expects($this->any()) ->method('getActorType') @@ -209,7 +209,7 @@ class CommentsNodeTest extends \Test\TestCase { $this->comment->expects($this->once()) ->method('setMessage') - ->will($this->throwException(new MessageTooLongException())); + ->willThrowException(new MessageTooLongException()); $this->comment->expects($this->any()) ->method('getActorType') @@ -469,9 +469,7 @@ class CommentsNodeTest extends \Test\TestCase { ]; } - /** - * @dataProvider readCommentProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('readCommentProvider')] public function testGetPropertiesUnreadProperty(\DateTime $creationDT, ?\DateTime $readDT, string $expected): void { $this->comment->expects($this->any()) ->method('getCreationDateTime') diff --git a/apps/dav/tests/unit/Comments/CommentsPluginTest.php b/apps/dav/tests/unit/Comments/CommentsPluginTest.php index 35638391e67..18d32772f7b 100644 --- a/apps/dav/tests/unit/Comments/CommentsPluginTest.php +++ b/apps/dav/tests/unit/Comments/CommentsPluginTest.php @@ -184,7 +184,7 @@ class CommentsPluginTest extends \Test\TestCase { $this->tree->expects($this->any()) ->method('getNodeForPath') ->with('/' . $path) - ->will($this->throwException(new \Sabre\DAV\Exception\NotFound())); + ->willThrowException(new \Sabre\DAV\Exception\NotFound()); $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() diff --git a/apps/dav/tests/unit/Comments/EntityCollectionTest.php b/apps/dav/tests/unit/Comments/EntityCollectionTest.php index fcf0748696c..29ebde7d602 100644 --- a/apps/dav/tests/unit/Comments/EntityCollectionTest.php +++ b/apps/dav/tests/unit/Comments/EntityCollectionTest.php @@ -68,7 +68,7 @@ class EntityCollectionTest extends \Test\TestCase { $this->commentsManager->expects($this->once()) ->method('get') ->with('55') - ->will($this->throwException(new NotFoundException())); + ->willThrowException(new NotFoundException()); $this->collection->getChild('55'); } @@ -114,7 +114,7 @@ class EntityCollectionTest extends \Test\TestCase { $this->commentsManager->expects($this->once()) ->method('get') ->with('44') - ->will($this->throwException(new NotFoundException())); + ->willThrowException(new NotFoundException()); $this->assertFalse($this->collection->childExists('44')); } diff --git a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php index 501ef3ef1d1..4b42a815708 100644 --- a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php @@ -196,7 +196,7 @@ class AuthTest extends TestCase { ->expects($this->once()) ->method('logClientIn') ->with('MyTestUser', 'MyTestPassword') - ->will($this->throwException(new PasswordLoginForbiddenException())); + ->willThrowException(new PasswordLoginForbiddenException()); $this->session ->expects($this->once()) ->method('close'); diff --git a/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php index 27ddd3f4a1f..366c9475b1b 100644 --- a/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php @@ -55,9 +55,7 @@ class BlockLegacyClientPluginTest extends TestCase { ]; } - /** - * @dataProvider oldDesktopClientProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('oldDesktopClientProvider')] public function testBeforeHandlerException(string $userAgent, ERROR_TYPE $errorType): void { $this->themingDefaults ->expects($this->atMost(1)) @@ -95,8 +93,8 @@ class BlockLegacyClientPluginTest extends TestCase { /** * Ensure that there is no room for XSS attack through configured URL / version - * @dataProvider oldDesktopClientProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('oldDesktopClientProvider')] public function testBeforeHandlerExceptionPreventXSSAttack(string $userAgent, ERROR_TYPE $errorType): void { $this->expectException(\Sabre\DAV\Exception\Forbidden::class); @@ -142,9 +140,7 @@ class BlockLegacyClientPluginTest extends TestCase { ]; } - /** - * @dataProvider newAndAlternateDesktopClientProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('newAndAlternateDesktopClientProvider')] public function testBeforeHandlerSuccess(string $userAgent): void { /** @var RequestInterface|MockObject $request */ $request = $this->createMock(RequestInterface::class); diff --git a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php index 6606dcd5717..a934d6401c2 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php @@ -43,9 +43,7 @@ class CommentsPropertiesPluginTest extends \Test\TestCase { ]; } - /** - * @dataProvider nodeProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('nodeProvider')] public function testHandleGetProperties(string $class, bool $expectedSuccessful): void { $propFind = $this->createMock(PropFind::class); @@ -69,9 +67,7 @@ class CommentsPropertiesPluginTest extends \Test\TestCase { ]; } - /** - * @dataProvider baseUriProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('baseUriProvider')] public function testGetCommentsLink(string $baseUri, string $fid, ?string $expectedHref): void { $node = $this->createMock(File::class); $node->expects($this->any()) @@ -93,9 +89,7 @@ class CommentsPropertiesPluginTest extends \Test\TestCase { ]; } - /** - * @dataProvider userProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('userProvider')] public function testGetUnreadCount(?string $user): void { $node = $this->createMock(File::class); $node->expects($this->any()) diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php index 85890c0f987..421ee1bdc12 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php @@ -373,26 +373,20 @@ class DirectoryTest extends \Test\TestCase { $this->assertEquals([200, 800], $dir->getQuotaInfo()); //200 used, 800 free } - /** - * @dataProvider moveFailedProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('moveFailedProvider')] public function testMoveFailed(string $source, string $destination, array $updatables, array $deletables): void { $this->expectException(\Sabre\DAV\Exception\Forbidden::class); $this->moveTest($source, $destination, $updatables, $deletables); } - /** - * @dataProvider moveSuccessProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('moveSuccessProvider')] public function testMoveSuccess(string $source, string $destination, array $updatables, array $deletables): void { $this->moveTest($source, $destination, $updatables, $deletables); $this->addToAssertionCount(1); } - /** - * @dataProvider moveFailedInvalidCharsProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('moveFailedInvalidCharsProvider')] public function testMoveFailedInvalidChars(string $source, string $destination, array $updatables, array $deletables): void { $this->expectException(InvalidPath::class); diff --git a/apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php index a330a885b1f..416ac8a75c9 100644 --- a/apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php @@ -42,9 +42,7 @@ class ExceptionLoggerPluginTest extends TestCase { $this->plugin->initialize($this->server); } - /** - * @dataProvider providesExceptions - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesExceptions')] public function testLogging(string $expectedLogLevel, \Throwable $e): void { $this->init(); diff --git a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php index ef744d13e6a..366932137f4 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php @@ -41,7 +41,7 @@ class FakeLockerPluginTest extends TestCase { ]; $server->expects($this->exactly(count($calls))) ->method('on') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); @@ -74,7 +74,7 @@ class FakeLockerPluginTest extends TestCase { ]; $propFind->expects($this->exactly(count($calls))) ->method('handle') - ->willReturnCallback(function ($propertyName) use (&$calls) { + ->willReturnCallback(function ($propertyName) use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, $propertyName); }); @@ -119,9 +119,7 @@ class FakeLockerPluginTest extends TestCase { ]; } - /** - * @dataProvider tokenDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('tokenDataProvider')] public function testValidateTokens(array $input, array $expected): void { $request = $this->createMock(RequestInterface::class); $this->fakeLockerPlugin->validateTokens($request, $input); diff --git a/apps/dav/tests/unit/Connector/Sabre/FileTest.php b/apps/dav/tests/unit/Connector/Sabre/FileTest.php index 4a7ddad7115..60c8382e131 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FileTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FileTest.php @@ -150,9 +150,7 @@ class FileTest extends TestCase { ]; } - /** - * @dataProvider fopenFailuresProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('fopenFailuresProvider')] public function testSimplePutFails(?\Throwable $thrownException, string $expectedException, bool $checkPreviousClass = true): void { // setup $storage = $this->getMockBuilder(Local::class) @@ -175,7 +173,7 @@ class FileTest extends TestCase { if ($thrownException !== null) { $storage->expects($this->once()) ->method('writeStream') - ->will($this->throwException($thrownException)); + ->willThrowException($thrownException); } else { $storage->expects($this->once()) ->method('writeStream') @@ -316,8 +314,8 @@ class FileTest extends TestCase { /** * Test putting a file with string Mtime - * @dataProvider legalMtimeProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('legalMtimeProvider')] public function testPutSingleFileLegalMtime(mixed $requestMtime, ?int $resultMtime): void { $request = new Request([ 'server' => [ diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php index d8b32067dda..4df3accfda9 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php @@ -294,7 +294,7 @@ class FilesPluginTest extends TestCase { $node->expects($this->once()) ->method('getDirectDownload') - ->will($this->throwException(new StorageNotAvailableException())); + ->willThrowException(new StorageNotAvailableException()); $this->plugin->handleGetProperties( $propFind, @@ -652,9 +652,7 @@ class FilesPluginTest extends TestCase { ]; } - /** - * @dataProvider downloadHeadersProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('downloadHeadersProvider')] public function testDownloadHeaders(bool $isClumsyAgent, string $contentDispositionHeader): void { $request = $this->createMock(RequestInterface::class); $response = $this->createMock(ResponseInterface::class); @@ -688,7 +686,7 @@ class FilesPluginTest extends TestCase { $response ->expects($this->exactly(count($calls))) ->method('addHeader') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertSame($expected, func_get_args()); }); diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php index e6cfb1f67b2..176949f999c 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php @@ -846,9 +846,7 @@ class FilesReportPluginTest extends \Test\TestCase { ]; } - /** - * @dataProvider filesBaseUriProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('filesBaseUriProvider')] public function testFilesBaseUri(string $uri, string $reportPath, string $expectedUri): void { $this->assertEquals($expectedUri, self::invokePrivate($this->plugin, 'getFilesBaseUri', [$uri, $reportPath])); } diff --git a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php index 3dea5cf281b..11970769a1e 100644 --- a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php @@ -51,9 +51,7 @@ class NodeTest extends \Test\TestCase { ]; } - /** - * @dataProvider davPermissionsProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('davPermissionsProvider')] public function testDavPermissions(int $permissions, string $type, bool $shared, int $shareRootPermissions, bool $mounted, string $internalPath, string $expected): void { $info = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor() @@ -141,9 +139,7 @@ class NodeTest extends \Test\TestCase { ]; } - /** - * @dataProvider sharePermissionsProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('sharePermissionsProvider')] public function testSharePermissions(string $type, ?string $user, int $permissions, int $expected): void { $storage = $this->createMock(IStorage::class); $storage->method('getPermissions')->willReturn($permissions); @@ -242,9 +238,7 @@ class NodeTest extends \Test\TestCase { ]; } - /** - * @dataProvider sanitizeMtimeProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('sanitizeMtimeProvider')] public function testSanitizeMtime(string|int $mtime, int $expected): void { $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor() @@ -264,9 +258,7 @@ class NodeTest extends \Test\TestCase { ]; } - /** - * @dataProvider invalidSanitizeMtimeProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('invalidSanitizeMtimeProvider')] public function testInvalidSanitizeMtime(int|string $mtime): void { $this->expectException(\InvalidArgumentException::class); diff --git a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php index 4a5937e365b..b07778e4fbd 100644 --- a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php @@ -39,9 +39,7 @@ class ObjectTreeTest extends \Test\TestCase { ]; } - /** - * @dataProvider copyDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('copyDataProvider')] public function testCopy(string $sourcePath, string $targetPath, string $targetParent): void { $view = $this->createMock(View::class); $view->expects($this->once()) @@ -83,9 +81,7 @@ class ObjectTreeTest extends \Test\TestCase { $objectTree->copy($sourcePath, $targetPath); } - /** - * @dataProvider copyDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('copyDataProvider')] public function testCopyFailNotCreatable($sourcePath, $targetPath, $targetParent): void { $this->expectException(\Sabre\DAV\Exception\Forbidden::class); @@ -124,9 +120,7 @@ class ObjectTreeTest extends \Test\TestCase { $objectTree->copy($sourcePath, $targetPath); } - /** - * @dataProvider nodeForPathProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('nodeForPathProvider')] public function testGetNodeForPath( string $inputFileName, string $fileInfoQueryPath, diff --git a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php index 087bbd66107..e32d2671063 100644 --- a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php @@ -463,9 +463,7 @@ class PrincipalTest extends TestCase { ['{http://sabredav.org/ns}email-address' => 'foo'])); } - /** - * @dataProvider searchPrincipalsDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('searchPrincipalsDataProvider')] public function testSearchPrincipals(bool $sharingEnabled, bool $groupsOnly, string $test, array $result): void { $this->shareManager->expects($this->once()) ->method('shareAPIEnabled') @@ -826,9 +824,7 @@ class PrincipalTest extends TestCase { $this->assertEquals(null, $this->connector->findByUri('mailto:user@foo.com', 'principals/users')); } - /** - * @dataProvider findByUriWithGroupRestrictionDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('findByUriWithGroupRestrictionDataProvider')] public function testFindByUriWithGroupRestriction(string $uri, string $email, ?string $expects): void { $this->shareManager->expects($this->once()) ->method('shareApiEnabled') @@ -879,9 +875,7 @@ class PrincipalTest extends TestCase { ]; } - /** - * @dataProvider findByUriWithoutGroupRestrictionDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('findByUriWithoutGroupRestrictionDataProvider')] public function testFindByUriWithoutGroupRestriction(string $uri, string $email, string $expects): void { $this->shareManager->expects($this->once()) ->method('shareApiEnabled') diff --git a/apps/dav/tests/unit/Connector/Sabre/PublicAuthTest.php b/apps/dav/tests/unit/Connector/Sabre/PublicAuthTest.php index 2340890ae5a..fef62b51c67 100644 --- a/apps/dav/tests/unit/Connector/Sabre/PublicAuthTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/PublicAuthTest.php @@ -114,7 +114,7 @@ class PublicAuthTest extends \Test\TestCase { ->expects($this->once()) ->method('getShareByToken') ->with('GX9HSGQrGE') - ->will($this->throwException(new ShareNotFound())); + ->willThrowException(new ShareNotFound()); $this->expectException(\Sabre\DAV\Exception\NotFound::class); self::invokePrivate($this->auth, 'checkToken'); diff --git a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php index a78a1a223c5..6fe2d6ccabe 100644 --- a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php @@ -25,9 +25,7 @@ class QuotaPluginTest extends TestCase { $this->plugin->initialize($this->server); } - /** - * @dataProvider lengthProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('lengthProvider')] public function testLength(?int $expected, array $headers): void { $this->init(0); @@ -36,9 +34,7 @@ class QuotaPluginTest extends TestCase { $this->assertEquals($expected, $length); } - /** - * @dataProvider quotaOkayProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('quotaOkayProvider')] public function testCheckQuota(int $quota, array $headers): void { $this->init($quota); @@ -47,9 +43,7 @@ class QuotaPluginTest extends TestCase { $this->assertTrue($result); } - /** - * @dataProvider quotaExceededProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('quotaExceededProvider')] public function testCheckExceededQuota(int $quota, array $headers): void { $this->expectException(\Sabre\DAV\Exception\InsufficientStorage::class); @@ -59,9 +53,7 @@ class QuotaPluginTest extends TestCase { $this->plugin->checkQuota(''); } - /** - * @dataProvider quotaOkayProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('quotaOkayProvider')] public function testCheckQuotaOnPath(int $quota, array $headers): void { $this->init($quota, 'sub/test.txt'); diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/DeleteTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/DeleteTest.php index c5c7e99c7e5..7d3488e6b5a 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/DeleteTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/DeleteTest.php @@ -9,6 +9,7 @@ declare(strict_types=1); namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest; use OCP\AppFramework\Http; +use OCP\Files\FileInfo; /** * Class DeleteTest @@ -30,7 +31,7 @@ class DeleteTest extends RequestTestCase { $mount->getStorage()->unlink($mount->getInternalPath($internalPath)); // cache entry still exists - $this->assertInstanceOf(\OCP\Files\FileInfo::class, $view->getFileInfo('foo.txt')); + $this->assertInstanceOf(FileInfo::class, $view->getFileInfo('foo.txt')); $response = $this->request($view, $user, 'pass', 'DELETE', '/foo.txt'); diff --git a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php index 00ac5b5543f..1c8e29dab38 100644 --- a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php @@ -54,9 +54,7 @@ class SharesPluginTest extends \Test\TestCase { $this->plugin->initialize($this->server); } - /** - * @dataProvider sharesGetPropertiesDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('sharesGetPropertiesDataProvider')] public function testGetProperties(array $shareTypes): void { $sabreNode = $this->createMock(Node::class); $sabreNode->expects($this->any()) @@ -119,9 +117,7 @@ class SharesPluginTest extends \Test\TestCase { $this->assertEquals($shareTypes, $result[200][self::SHARETYPES_PROPERTYNAME]->getShareTypes()); } - /** - * @dataProvider sharesGetPropertiesDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('sharesGetPropertiesDataProvider')] public function testPreloadThenGetProperties(array $shareTypes): void { $sabreNode1 = $this->createMock(File::class); $sabreNode1->method('getId') diff --git a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php index bef508e08ca..5003280bfdc 100644 --- a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php @@ -58,9 +58,7 @@ class TagsPluginTest extends \Test\TestCase { $this->plugin->initialize($this->server); } - /** - * @dataProvider tagsGetPropertiesDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('tagsGetPropertiesDataProvider')] public function testGetProperties(array $tags, array $requestedProperties, array $expectedProperties): void { $node = $this->createMock(Node::class); $node->expects($this->any()) @@ -95,9 +93,7 @@ class TagsPluginTest extends \Test\TestCase { $this->assertEquals($expectedProperties, $result); } - /** - * @dataProvider tagsGetPropertiesDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('tagsGetPropertiesDataProvider')] public function testPreloadThenGetProperties(array $tags, array $requestedProperties, array $expectedProperties): void { $node1 = $this->createMock(File::class); $node1->expects($this->any()) @@ -269,7 +265,7 @@ class TagsPluginTest extends \Test\TestCase { ]; $this->tagger->expects($this->exactly(count($calls))) ->method('tagAs') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); @@ -322,7 +318,7 @@ class TagsPluginTest extends \Test\TestCase { ]; $this->tagger->expects($this->exactly(count($calls))) ->method('tagAs') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); diff --git a/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php b/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php index 895a84b8404..15b18d6c1b1 100644 --- a/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php +++ b/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php @@ -53,9 +53,7 @@ class InvitationResponseControllerTest extends TestCase { ]; } - /** - * @dataProvider attendeeProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('attendeeProvider')] public function testAccept(bool $isExternalAttendee): void { $this->buildQueryExpects('TOKEN123', [ 'id' => 0, @@ -117,9 +115,7 @@ EOF; $this->assertTrue($called); } - /** - * @dataProvider attendeeProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('attendeeProvider')] public function testAcceptSequence(bool $isExternalAttendee): void { $this->buildQueryExpects('TOKEN123', [ 'id' => 0, @@ -181,9 +177,7 @@ EOF; $this->assertTrue($called); } - /** - * @dataProvider attendeeProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('attendeeProvider')] public function testAcceptRecurrenceId(bool $isExternalAttendee): void { $this->buildQueryExpects('TOKEN123', [ 'id' => 0, @@ -273,9 +267,7 @@ EOF; $this->assertEquals([], $response->getParams()); } - /** - * @dataProvider attendeeProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('attendeeProvider')] public function testDecline(bool $isExternalAttendee): void { $this->buildQueryExpects('TOKEN123', [ 'id' => 0, @@ -344,9 +336,7 @@ EOF; $this->assertEquals(['token' => 'TOKEN123'], $response->getParams()); } - /** - * @dataProvider attendeeProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('attendeeProvider')] public function testProcessMoreOptionsResult(bool $isExternalAttendee): void { $this->request->expects($this->once()) ->method('getParam') diff --git a/apps/dav/tests/unit/DAV/BrowserErrorPagePluginTest.php b/apps/dav/tests/unit/DAV/BrowserErrorPagePluginTest.php index 23ee2b66f77..0e82ef0a3ae 100644 --- a/apps/dav/tests/unit/DAV/BrowserErrorPagePluginTest.php +++ b/apps/dav/tests/unit/DAV/BrowserErrorPagePluginTest.php @@ -15,9 +15,7 @@ use Sabre\HTTP\Response; class BrowserErrorPagePluginTest extends \Test\TestCase { - /** - * @dataProvider providesExceptions - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesExceptions')] public function test(int $expectedCode, \Throwable $exception): void { /** @var BrowserErrorPagePlugin&MockObject $plugin */ $plugin = $this->getMockBuilder(BrowserErrorPagePlugin::class)->onlyMethods(['sendResponse', 'generateBody'])->getMock(); diff --git a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php index 7c77b3fcb28..2a85c0cbecd 100644 --- a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php +++ b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php @@ -271,9 +271,7 @@ class CustomPropertiesBackendTest extends TestCase { } - /** - * @dataProvider propFindPrincipalScheduleDefaultCalendarProviderUrlProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('propFindPrincipalScheduleDefaultCalendarProviderUrlProvider')] public function testPropFindPrincipalScheduleDefaultCalendarUrl( string $user, array $nodes, @@ -335,9 +333,7 @@ class CustomPropertiesBackendTest extends TestCase { $this->assertEquals($returnedProps, $setProps); } - /** - * @dataProvider propPatchProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('propPatchProvider')] public function testPropPatch(string $path, array $existing, array $props, array $result): void { $this->server->method('calculateUri') ->willReturnCallback(function ($uri) { @@ -418,9 +414,7 @@ class CustomPropertiesBackendTest extends TestCase { $this->assertEquals([], $storedProps); } - /** - * @dataProvider deleteProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('deleteProvider')] public function testDelete(string $path): void { $this->insertProps('dummy_user_42', $path, ['foo' => 'bar']); $this->backend->delete($path); @@ -434,9 +428,7 @@ class CustomPropertiesBackendTest extends TestCase { ]; } - /** - * @dataProvider moveProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('moveProvider')] public function testMove(string $source, string $target): void { $this->insertProps('dummy_user_42', $source, ['foo' => 'bar']); $this->backend->move($source, $target); diff --git a/apps/dav/tests/unit/DAV/GroupPrincipalTest.php b/apps/dav/tests/unit/DAV/GroupPrincipalTest.php index 2ede450c36b..2756152a6e2 100644 --- a/apps/dav/tests/unit/DAV/GroupPrincipalTest.php +++ b/apps/dav/tests/unit/DAV/GroupPrincipalTest.php @@ -192,9 +192,7 @@ class GroupPrincipalTest extends \Test\TestCase { ['{DAV:}displayname' => 'Foo'])); } - /** - * @dataProvider searchPrincipalsDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('searchPrincipalsDataProvider')] public function testSearchPrincipals(bool $sharingEnabled, bool $groupSharingEnabled, bool $groupsOnly, string $test, array $result): void { $this->shareManager->expects($this->once()) ->method('shareAPIEnabled') @@ -265,9 +263,7 @@ class GroupPrincipalTest extends \Test\TestCase { ]; } - /** - * @dataProvider findByUriDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('findByUriDataProvider')] public function testFindByUri(bool $sharingEnabled, bool $groupSharingEnabled, bool $groupsOnly, string $findUri, ?string $result): void { $this->shareManager->expects($this->once()) ->method('shareAPIEnabled') diff --git a/apps/dav/tests/unit/DAV/SystemPrincipalBackendTest.php b/apps/dav/tests/unit/DAV/SystemPrincipalBackendTest.php index 127de1ede0a..3df861accf2 100644 --- a/apps/dav/tests/unit/DAV/SystemPrincipalBackendTest.php +++ b/apps/dav/tests/unit/DAV/SystemPrincipalBackendTest.php @@ -14,9 +14,7 @@ use Test\TestCase; class SystemPrincipalBackendTest extends TestCase { - /** - * @dataProvider providesPrefix - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesPrefix')] public function testGetPrincipalsByPrefix(array $expected, string $prefix): void { $backend = new SystemPrincipalBackend(); $result = $backend->getPrincipalsByPrefix($prefix); @@ -38,9 +36,7 @@ class SystemPrincipalBackendTest extends TestCase { ]; } - /** - * @dataProvider providesPath - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesPath')] public function testGetPrincipalByPath(?array $expected, string $path): void { $backend = new SystemPrincipalBackend(); $result = $backend->getPrincipalByPath($path); @@ -59,9 +55,7 @@ class SystemPrincipalBackendTest extends TestCase { ]; } - /** - * @dataProvider providesPrincipalForGetGroupMemberSet - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesPrincipalForGetGroupMemberSet')] public function testGetGroupMemberSetExceptional(?string $principal): void { $this->expectException(Exception::class); $this->expectExceptionMessage('Principal not found'); @@ -83,9 +77,7 @@ class SystemPrincipalBackendTest extends TestCase { $this->assertEquals(['principals/system/system'], $result); } - /** - * @dataProvider providesPrincipalForGetGroupMembership - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesPrincipalForGetGroupMembership')] public function testGetGroupMembershipExceptional(string $principal): void { $this->expectException(Exception::class); $this->expectExceptionMessage('Principal not found'); diff --git a/apps/dav/tests/unit/DAV/ViewOnlyPluginTest.php b/apps/dav/tests/unit/DAV/ViewOnlyPluginTest.php index ecb71bb7ae7..eefbc53fd22 100644 --- a/apps/dav/tests/unit/DAV/ViewOnlyPluginTest.php +++ b/apps/dav/tests/unit/DAV/ViewOnlyPluginTest.php @@ -94,9 +94,7 @@ class ViewOnlyPluginTest extends TestCase { ]; } - /** - * @dataProvider providesDataForCanGet - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesDataForCanGet')] public function testCanGet(bool $isVersion, ?bool $attrEnabled, bool $expectCanDownloadFile, bool $allowViewWithoutDownload): void { $nodeInfo = $this->createMock(File::class); if ($isVersion) { diff --git a/apps/dav/tests/unit/Listener/ActivityUpdaterListenerTest.php b/apps/dav/tests/unit/Listener/ActivityUpdaterListenerTest.php index 7bd7bdc2167..8519dca7126 100644 --- a/apps/dav/tests/unit/Listener/ActivityUpdaterListenerTest.php +++ b/apps/dav/tests/unit/Listener/ActivityUpdaterListenerTest.php @@ -36,9 +36,7 @@ class ActivityUpdaterListenerTest extends TestCase { ); } - /** - * @dataProvider dataForTestHandleCalendarObjectDeletedEvent - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataForTestHandleCalendarObjectDeletedEvent')] public function testHandleCalendarObjectDeletedEvent(int $calendarId, array $calendarData, array $shares, array $objectData, bool $createsActivity): void { $event = new CalendarObjectDeletedEvent($calendarId, $calendarData, $shares, $objectData); $this->logger->expects($this->once())->method('debug')->with( @@ -60,9 +58,7 @@ class ActivityUpdaterListenerTest extends TestCase { ]; } - /** - * @dataProvider dataForTestHandleCalendarDeletedEvent - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataForTestHandleCalendarDeletedEvent')] public function testHandleCalendarDeletedEvent(int $calendarId, array $calendarData, array $shares, bool $createsActivity): void { $event = new CalendarDeletedEvent($calendarId, $calendarData, $shares); $this->logger->expects($this->once())->method('debug')->with( diff --git a/apps/dav/tests/unit/Migration/RefreshWebcalJobRegistrarTest.php b/apps/dav/tests/unit/Migration/RefreshWebcalJobRegistrarTest.php index 73d9c1efd29..8e7bf366cbf 100644 --- a/apps/dav/tests/unit/Migration/RefreshWebcalJobRegistrarTest.php +++ b/apps/dav/tests/unit/Migration/RefreshWebcalJobRegistrarTest.php @@ -105,7 +105,7 @@ class RefreshWebcalJobRegistrarTest extends TestCase { ]; $this->jobList->expects($this->exactly(2)) ->method('add') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); diff --git a/apps/dav/tests/unit/Migration/RemoveDeletedUsersCalendarSubscriptionsTest.php b/apps/dav/tests/unit/Migration/RemoveDeletedUsersCalendarSubscriptionsTest.php index 0a646e91602..a9758470573 100644 --- a/apps/dav/tests/unit/Migration/RemoveDeletedUsersCalendarSubscriptionsTest.php +++ b/apps/dav/tests/unit/Migration/RemoveDeletedUsersCalendarSubscriptionsTest.php @@ -45,9 +45,7 @@ class RemoveDeletedUsersCalendarSubscriptionsTest extends TestCase { ); } - /** - * @dataProvider dataTestRun - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestRun')] public function testRun(array $subscriptions, array $userExists, int $deletions): void { $qb = $this->createMock(IQueryBuilder::class); diff --git a/apps/dav/tests/unit/Provisioning/Apple/AppleProvisioningPluginTest.php b/apps/dav/tests/unit/Provisioning/Apple/AppleProvisioningPluginTest.php index ba44efe7421..58e588aa68d 100644 --- a/apps/dav/tests/unit/Provisioning/Apple/AppleProvisioningPluginTest.php +++ b/apps/dav/tests/unit/Provisioning/Apple/AppleProvisioningPluginTest.php @@ -153,7 +153,7 @@ class AppleProvisioningPluginTest extends TestCase { ]; $this->sabreResponse->expects($this->exactly(2)) ->method('setHeader') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); diff --git a/apps/dav/tests/unit/Search/EventsSearchProviderTest.php b/apps/dav/tests/unit/Search/EventsSearchProviderTest.php index fb8d111ad26..d5d536fd201 100644 --- a/apps/dav/tests/unit/Search/EventsSearchProviderTest.php +++ b/apps/dav/tests/unit/Search/EventsSearchProviderTest.php @@ -418,9 +418,7 @@ class EventsSearchProviderTest extends TestCase { $this->assertEquals('absolute-url-to-route', $actual); } - /** - * @dataProvider generateSublineDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('generateSublineDataProvider')] public function testGenerateSubline(string $ics, string $expectedSubline): void { $vCalendar = Reader::read($ics, Reader::OPTION_FORGIVING); $eventComponent = $vCalendar->VEVENT; diff --git a/apps/dav/tests/unit/Search/TasksSearchProviderTest.php b/apps/dav/tests/unit/Search/TasksSearchProviderTest.php index 972db0b98ba..7f9a2842de9 100644 --- a/apps/dav/tests/unit/Search/TasksSearchProviderTest.php +++ b/apps/dav/tests/unit/Search/TasksSearchProviderTest.php @@ -289,9 +289,7 @@ class TasksSearchProviderTest extends TestCase { $this->assertEquals('absolute-url-link-to-route-tasks.indexcalendars/uri-john.doe/tasks/task-uri.ics', $actual); } - /** - * @dataProvider generateSublineDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('generateSublineDataProvider')] public function testGenerateSubline(string $ics, string $expectedSubline): void { $vCalendar = Reader::read($ics, Reader::OPTION_FORGIVING); $taskComponent = $vCalendar->VTODO; diff --git a/apps/dav/tests/unit/ServerTest.php b/apps/dav/tests/unit/ServerTest.php index 0baef015056..9ffe86d3053 100644 --- a/apps/dav/tests/unit/ServerTest.php +++ b/apps/dav/tests/unit/ServerTest.php @@ -20,9 +20,7 @@ use OCP\IRequest; */ class ServerTest extends \Test\TestCase { - /** - * @dataProvider providesUris - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesUris')] public function test(string $uri, array $plugins): void { /** @var IRequest | \PHPUnit\Framework\MockObject\MockObject $r */ $r = $this->createMock(IRequest::class); diff --git a/apps/dav/tests/unit/Service/ExampleContactServiceTest.php b/apps/dav/tests/unit/Service/ExampleContactServiceTest.php index 4c8d900ae86..027b66a6fb2 100644 --- a/apps/dav/tests/unit/Service/ExampleContactServiceTest.php +++ b/apps/dav/tests/unit/Service/ExampleContactServiceTest.php @@ -173,7 +173,7 @@ class ExampleContactServiceTest extends TestCase { return [[true], [false]]; } - /** @dataProvider provideDefaultContactEnableData */ + #[\PHPUnit\Framework\Attributes\DataProvider('provideDefaultContactEnableData')] public function testIsDefaultContactEnabled(bool $enabled): void { $this->appConfig->expects(self::once()) ->method('getAppValueBool') @@ -183,7 +183,7 @@ class ExampleContactServiceTest extends TestCase { $this->assertEquals($enabled, $this->service->isDefaultContactEnabled()); } - /** @dataProvider provideDefaultContactEnableData */ + #[\PHPUnit\Framework\Attributes\DataProvider('provideDefaultContactEnableData')] public function testSetDefaultContactEnabled(bool $enabled): void { $this->appConfig->expects(self::once()) ->method('setAppValueBool') diff --git a/apps/dav/tests/unit/Service/ExampleEventServiceTest.php b/apps/dav/tests/unit/Service/ExampleEventServiceTest.php index e5961e66312..0f423624fb8 100644 --- a/apps/dav/tests/unit/Service/ExampleEventServiceTest.php +++ b/apps/dav/tests/unit/Service/ExampleEventServiceTest.php @@ -62,7 +62,7 @@ class ExampleEventServiceTest extends TestCase { ]; } - /** @dataProvider provideCustomEventData */ + #[\PHPUnit\Framework\Attributes\DataProvider('provideCustomEventData')] public function testCreateExampleEventWithCustomEvent($customEventIcs): void { $this->appConfig->expects(self::once()) ->method('getValueBool') @@ -142,7 +142,7 @@ class ExampleEventServiceTest extends TestCase { $this->service->createExampleEvent(1000); } - /** @dataProvider provideCustomEventData */ + #[\PHPUnit\Framework\Attributes\DataProvider('provideCustomEventData')] public function testGetExampleEventWithCustomEvent($customEventIcs): void { $exampleEventFolder = $this->createMock(ISimpleFolder::class); $this->appData->expects(self::once()) diff --git a/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php b/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php index df7a08d5d08..032759d64b7 100644 --- a/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php +++ b/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php @@ -57,7 +57,7 @@ class CalDAVSettingsTest extends TestCase { ['sendEventRemindersPush', true], ]; $this->initialState->method('provideInitialState') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); diff --git a/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php b/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php index 0096b188291..39342811377 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php @@ -107,9 +107,7 @@ class SystemTagMappingNodeTest extends \Test\TestCase { ]; } - /** - * @dataProvider tagNodeDeleteProviderPermissionException - */ + #[\PHPUnit\Framework\Attributes\DataProvider('tagNodeDeleteProviderPermissionException')] public function testDeleteTagExpectedException(ISystemTag $tag, $expectedException): void { $this->tagManager->expects($this->any()) ->method('canUserSeeTag') @@ -152,7 +150,7 @@ class SystemTagMappingNodeTest extends \Test\TestCase { $this->tagMapper->expects($this->once()) ->method('unassignTags') ->with(123, 'files', 1) - ->will($this->throwException(new TagNotFoundException())); + ->willThrowException(new TagNotFoundException()); $this->getMappingNode($tag, [123])->delete(); } diff --git a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php index 642cc21319b..594b5e15db6 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php @@ -49,9 +49,7 @@ class SystemTagNodeTest extends \Test\TestCase { return [[true], [false]]; } - /** - * @dataProvider adminFlagProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('adminFlagProvider')] public function testGetters(bool $isAdmin): void { $tag = new SystemTag('1', 'Test', true, true); $node = $this->getTagNode($isAdmin, $tag); @@ -89,9 +87,7 @@ class SystemTagNodeTest extends \Test\TestCase { ]; } - /** - * @dataProvider tagNodeProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('tagNodeProvider')] public function testUpdateTag(bool $isAdmin, ISystemTag $originalTag, array $changedArgs): void { $this->tagManager->expects($this->once()) ->method('canUserSeeTag') @@ -149,9 +145,7 @@ class SystemTagNodeTest extends \Test\TestCase { ]; } - /** - * @dataProvider tagNodeProviderPermissionException - */ + #[\PHPUnit\Framework\Attributes\DataProvider('tagNodeProviderPermissionException')] public function testUpdateTagPermissionException(ISystemTag $originalTag, array $changedArgs, string $expectedException): void { $this->tagManager->expects($this->any()) ->method('canUserSeeTag') @@ -192,7 +186,7 @@ class SystemTagNodeTest extends \Test\TestCase { $this->tagManager->expects($this->once()) ->method('updateTag') ->with(1, 'Renamed', true, true) - ->will($this->throwException(new TagAlreadyExistsException())); + ->willThrowException(new TagAlreadyExistsException()); $this->getTagNode(false, $tag)->update('Renamed', true, true, null); } @@ -212,13 +206,11 @@ class SystemTagNodeTest extends \Test\TestCase { $this->tagManager->expects($this->once()) ->method('updateTag') ->with(1, 'Renamed', true, true) - ->will($this->throwException(new TagNotFoundException())); + ->willThrowException(new TagNotFoundException()); $this->getTagNode(false, $tag)->update('Renamed', true, true, null); } - /** - * @dataProvider adminFlagProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('adminFlagProvider')] public function testDeleteTag(bool $isAdmin): void { $tag = new SystemTag('1', 'tag1', true, true); $this->tagManager->expects($isAdmin ? $this->once() : $this->never()) @@ -249,9 +241,7 @@ class SystemTagNodeTest extends \Test\TestCase { ]; } - /** - * @dataProvider tagNodeDeleteProviderPermissionException - */ + #[\PHPUnit\Framework\Attributes\DataProvider('tagNodeDeleteProviderPermissionException')] public function testDeleteTagPermissionException(ISystemTag $tag, string $expectedException): void { $this->tagManager->expects($this->any()) ->method('canUserSeeTag') @@ -276,7 +266,7 @@ class SystemTagNodeTest extends \Test\TestCase { $this->tagManager->expects($this->once()) ->method('deleteTags') ->with('1') - ->will($this->throwException(new TagNotFoundException())); + ->willThrowException(new TagNotFoundException()); $this->getTagNode(true, $tag)->delete(); } } diff --git a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php index a9368794cc2..e0c4685c1fb 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php @@ -142,9 +142,7 @@ class SystemTagPluginTest extends \Test\TestCase { ]; } - /** - * @dataProvider getPropertiesDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('getPropertiesDataProvider')] public function testGetProperties(ISystemTag $systemTag, array $groups, array $requestedProperties, array $expectedProperties): void { $this->user->expects($this->any()) ->method('getUID') @@ -341,9 +339,7 @@ class SystemTagPluginTest extends \Test\TestCase { [true, true, 'group1|group2'], ]; } - /** - * @dataProvider createTagInsufficientPermissionsProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('createTagInsufficientPermissionsProvider')] public function testCreateNotAssignableTagAsRegularUser(bool $userVisible, bool $userAssignable, string $groups): void { $this->expectException(\Sabre\DAV\Exception\BadRequest::class); $this->expectExceptionMessage('Not sufficient permissions'); @@ -452,9 +448,7 @@ class SystemTagPluginTest extends \Test\TestCase { ]; } - /** - * @dataProvider createTagProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('createTagProvider')] public function testCreateTagInByIdCollection(bool $userVisible, bool $userAssignable, string $groups): void { $this->user->expects($this->once()) ->method('getUID') @@ -601,7 +595,7 @@ class SystemTagPluginTest extends \Test\TestCase { $this->tree->expects($this->any()) ->method('getNodeForPath') - ->will($this->throwException(new \Sabre\DAV\Exception\NotFound())); + ->willThrowException(new \Sabre\DAV\Exception\NotFound()); $this->tagManager->expects($this->never()) ->method('createTag'); @@ -619,9 +613,7 @@ class SystemTagPluginTest extends \Test\TestCase { $this->plugin->httpPost($request, $response); } - /** - * @dataProvider nodeClassProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('nodeClassProvider')] public function testCreateTagConflict(string $nodeClass): void { $this->expectException(\Sabre\DAV\Exception\Conflict::class); @@ -644,7 +636,7 @@ class SystemTagPluginTest extends \Test\TestCase { $this->tagManager->expects($this->once()) ->method('createTag') ->with('Test', true, false) - ->will($this->throwException(new TagAlreadyExistsException('Tag already exists'))); + ->willThrowException(new TagAlreadyExistsException('Tag already exists')); $this->tree->expects($this->any()) ->method('getNodeForPath') diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php index a6c97af26b4..8f7848452fe 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php @@ -101,7 +101,7 @@ class SystemTagsByIdCollectionTest extends \Test\TestCase { $this->tagManager->expects($this->once()) ->method('getTagsByIds') ->with(['invalid']) - ->will($this->throwException(new \InvalidArgumentException())); + ->willThrowException(new \InvalidArgumentException()); $this->getNode()->getChild('invalid'); } @@ -113,7 +113,7 @@ class SystemTagsByIdCollectionTest extends \Test\TestCase { $this->tagManager->expects($this->once()) ->method('getTagsByIds') ->with(['444']) - ->will($this->throwException(new TagNotFoundException())); + ->willThrowException(new TagNotFoundException()); $this->getNode()->getChild('444'); } @@ -185,9 +185,7 @@ class SystemTagsByIdCollectionTest extends \Test\TestCase { ]; } - /** - * @dataProvider childExistsProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('childExistsProvider')] public function testChildExists(bool $userVisible, bool $expectedResult): void { $tag = new SystemTag('123', 'One', $userVisible, false); $this->tagManager->expects($this->once()) @@ -207,7 +205,7 @@ class SystemTagsByIdCollectionTest extends \Test\TestCase { $this->tagManager->expects($this->once()) ->method('getTagsByIds') ->with(['123']) - ->will($this->throwException(new TagNotFoundException())); + ->willThrowException(new TagNotFoundException()); $this->assertFalse($this->getNode()->childExists('123')); } @@ -219,7 +217,7 @@ class SystemTagsByIdCollectionTest extends \Test\TestCase { $this->tagManager->expects($this->once()) ->method('getTagsByIds') ->with(['invalid']) - ->will($this->throwException(new \InvalidArgumentException())); + ->willThrowException(new \InvalidArgumentException()); $this->getNode()->childExists('invalid'); } diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php index 59cd3955f1f..5aea1242e2a 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php @@ -93,9 +93,7 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase { ]; } - /** - * @dataProvider permissionsProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('permissionsProvider')] public function testAssignTagNoPermission(bool $userVisible, bool $userAssignable, string $expectedException): void { $tag = new SystemTag('1', 'Test', $userVisible, $userAssignable); $this->tagManager->expects($this->once()) @@ -131,7 +129,7 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase { $this->tagManager->expects($this->once()) ->method('getTagsByIds') ->with(['555']) - ->will($this->throwException(new TagNotFoundException())); + ->willThrowException(new TagNotFoundException()); $this->getNode()->createFile('555'); } @@ -208,7 +206,7 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase { $this->tagMapper->expects($this->once()) ->method('haveTag') ->with([111], 'files', 'badid') - ->will($this->throwException(new \InvalidArgumentException())); + ->willThrowException(new \InvalidArgumentException()); $this->getNode()->getChild('badid'); } @@ -220,7 +218,7 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase { $this->tagMapper->expects($this->once()) ->method('haveTag') ->with([111], 'files', '777') - ->will($this->throwException(new TagNotFoundException())); + ->willThrowException(new TagNotFoundException()); $this->getNode()->getChild('777'); } @@ -312,7 +310,7 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase { $this->tagMapper->expects($this->once()) ->method('haveTag') ->with([111], 'files', '555') - ->will($this->throwException(new TagNotFoundException())); + ->willThrowException(new TagNotFoundException()); $this->assertFalse($this->getNode()->childExists('555')); } @@ -324,7 +322,7 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase { $this->tagMapper->expects($this->once()) ->method('haveTag') ->with([111], 'files', '555') - ->will($this->throwException(new \InvalidArgumentException())); + ->willThrowException(new \InvalidArgumentException()); $this->getNode()->childExists('555'); } diff --git a/apps/dav/tests/unit/Upload/AssemblyStreamTest.php b/apps/dav/tests/unit/Upload/AssemblyStreamTest.php index e0bc3c589bc..ec5d0a9ab5b 100644 --- a/apps/dav/tests/unit/Upload/AssemblyStreamTest.php +++ b/apps/dav/tests/unit/Upload/AssemblyStreamTest.php @@ -12,9 +12,7 @@ use Sabre\DAV\File; class AssemblyStreamTest extends \Test\TestCase { - /** - * @dataProvider providesNodes() - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesNodes')] public function testGetContents(string $expected, array $nodeData): void { $nodes = []; foreach ($nodeData as $data) { @@ -26,9 +24,7 @@ class AssemblyStreamTest extends \Test\TestCase { $this->assertEquals($expected, $content); } - /** - * @dataProvider providesNodes() - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesNodes')] public function testGetContentsFread(string $expected, array $nodeData, int $chunkLength = 3): void { $nodes = []; foreach ($nodeData as $data) { @@ -48,9 +44,7 @@ class AssemblyStreamTest extends \Test\TestCase { $this->assertEquals($expected, $content); } - /** - * @dataProvider providesNodes() - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesNodes')] public function testSeek(string $expected, array $nodeData): void { $nodes = []; foreach ($nodeData as $data) { diff --git a/apps/dav/tests/unit/Upload/UploadAutoMkcolPluginTest.php b/apps/dav/tests/unit/Upload/UploadAutoMkcolPluginTest.php index 9467b5df249..baae839c8da 100644 --- a/apps/dav/tests/unit/Upload/UploadAutoMkcolPluginTest.php +++ b/apps/dav/tests/unit/Upload/UploadAutoMkcolPluginTest.php @@ -50,9 +50,7 @@ class UploadAutoMkcolPluginTest extends TestCase { $this->assertTrue($return); } - /** - * @dataProvider dataMissingHeaderShouldReturnTrue - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataMissingHeaderShouldReturnTrue')] public function testBeforeMethodWithMissingHeaderShouldReturnTrue(?string $header): void { $this->request->expects(self::once()) ->method('getHeader') diff --git a/apps/encryption/tests/Command/TestEnableMasterKey.php b/apps/encryption/tests/Command/TestEnableMasterKey.php index 744bbaed6f8..ead3dfd0195 100644 --- a/apps/encryption/tests/Command/TestEnableMasterKey.php +++ b/apps/encryption/tests/Command/TestEnableMasterKey.php @@ -55,11 +55,11 @@ class TestEnableMasterKey extends TestCase { } /** - * @dataProvider dataTestExecute * * @param bool $isAlreadyEnabled * @param string $answer */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestExecute')] public function testExecute($isAlreadyEnabled, $answer): void { $this->util->expects($this->once())->method('isMasterKeyEnabled') ->willReturn($isAlreadyEnabled); @@ -81,7 +81,7 @@ class TestEnableMasterKey extends TestCase { $this->invokePrivate($this->enableMasterKey, 'execute', [$this->input, $this->output]); } - public function dataTestExecute() { + public static function dataTestExecute() { return [ [true, ''], [false, 'y'], diff --git a/apps/encryption/tests/Controller/RecoveryControllerTest.php b/apps/encryption/tests/Controller/RecoveryControllerTest.php index 7eff312d6ce..0fec3f4d6a9 100644 --- a/apps/encryption/tests/Controller/RecoveryControllerTest.php +++ b/apps/encryption/tests/Controller/RecoveryControllerTest.php @@ -37,13 +37,13 @@ class RecoveryControllerTest extends TestCase { } /** - * @dataProvider adminRecoveryProvider * @param $recoveryPassword * @param $passConfirm * @param $enableRecovery * @param $expectedMessage * @param $expectedStatus */ + #[\PHPUnit\Framework\Attributes\DataProvider('adminRecoveryProvider')] public function testAdminRecovery($recoveryPassword, $passConfirm, $enableRecovery, $expectedMessage, $expectedStatus): void { $this->recoveryMock->expects($this->any()) ->method('enableAdminRecovery') @@ -73,13 +73,13 @@ class RecoveryControllerTest extends TestCase { } /** - * @dataProvider changeRecoveryPasswordProvider * @param $password * @param $confirmPassword * @param $oldPassword * @param $expectedMessage * @param $expectedStatus */ + #[\PHPUnit\Framework\Attributes\DataProvider('changeRecoveryPasswordProvider')] public function testChangeRecoveryPassword($password, $confirmPassword, $oldPassword, $expectedMessage, $expectedStatus): void { $this->recoveryMock->expects($this->any()) ->method('changeRecoveryKeyPassword') @@ -105,11 +105,11 @@ class RecoveryControllerTest extends TestCase { } /** - * @dataProvider userSetRecoveryProvider * @param $enableRecovery * @param $expectedMessage * @param $expectedStatus */ + #[\PHPUnit\Framework\Attributes\DataProvider('userSetRecoveryProvider')] public function testUserSetRecovery($enableRecovery, $expectedMessage, $expectedStatus): void { $this->recoveryMock->expects($this->any()) ->method('setRecoveryForUser') diff --git a/apps/encryption/tests/Controller/StatusControllerTest.php b/apps/encryption/tests/Controller/StatusControllerTest.php index 616114927e8..1bbcad77411 100644 --- a/apps/encryption/tests/Controller/StatusControllerTest.php +++ b/apps/encryption/tests/Controller/StatusControllerTest.php @@ -50,11 +50,11 @@ class StatusControllerTest extends TestCase { } /** - * @dataProvider dataTestGetStatus * * @param string $status * @param string $expectedStatus */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetStatus')] public function testGetStatus($status, $expectedStatus): void { $this->sessionMock->expects($this->once()) ->method('getStatus')->willReturn($status); diff --git a/apps/encryption/tests/Crypto/CryptTest.php b/apps/encryption/tests/Crypto/CryptTest.php index 345311da4d0..1355e2c855d 100644 --- a/apps/encryption/tests/Crypto/CryptTest.php +++ b/apps/encryption/tests/Crypto/CryptTest.php @@ -80,9 +80,8 @@ class CryptTest extends TestCase { /** * test generateHeader with valid key formats - * - * @dataProvider dataTestGenerateHeader */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGenerateHeader')] public function testGenerateHeader($keyFormat, $expected): void { $this->config->expects($this->once()) ->method('getSystemValueString') @@ -130,10 +129,10 @@ class CryptTest extends TestCase { } /** - * @dataProvider dataProviderGetCipher * @param string $configValue * @param string $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataProviderGetCipher')] public function testGetCipher($configValue, $expected): void { $this->config->expects($this->once()) ->method('getSystemValueString') @@ -173,9 +172,7 @@ class CryptTest extends TestCase { ); } - /** - * @dataProvider dataTestSplitMetaData - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSplitMetaData')] public function testSplitMetaData($data, $expected): void { $this->config->method('getSystemValueBool') ->with('encryption_skip_signature_check', false) @@ -200,9 +197,7 @@ class CryptTest extends TestCase { ]; } - /** - * @dataProvider dataTestHasSignature - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestHasSignature')] public function testHasSignature($data, $expected): void { $this->config->method('getSystemValueBool') ->with('encryption_skip_signature_check', false) @@ -219,9 +214,7 @@ class CryptTest extends TestCase { ]; } - /** - * @dataProvider dataTestHasSignatureFail - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestHasSignatureFail')] public function testHasSignatureFail($cipher): void { $this->expectException(GenericEncryptionException::class); @@ -249,10 +242,10 @@ class CryptTest extends TestCase { /** * test removePadding() * - * @dataProvider dataProviderRemovePadding * @param $data * @param $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataProviderRemovePadding')] public function testRemovePadding($data, $expected): void { $result = self::invokePrivate($this->crypt, 'removePadding', [$data]); $this->assertSame($expected, $result); @@ -327,9 +320,8 @@ class CryptTest extends TestCase { /** * test return values of valid ciphers - * - * @dataProvider dataTestGetKeySize */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetKeySize')] public function testGetKeySize($cipher, $expected): void { $result = $this->invokePrivate($this->crypt, 'getKeySize', [$cipher]); $this->assertSame($expected, $result); @@ -354,9 +346,7 @@ class CryptTest extends TestCase { ]; } - /** - * @dataProvider dataTestDecryptPrivateKey - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestDecryptPrivateKey')] public function testDecryptPrivateKey($header, $privateKey, $expectedCipher, $isValidKey, $expected): void { $this->config->method('getSystemValueBool') ->willReturnMap([ diff --git a/apps/encryption/tests/Crypto/DecryptAllTest.php b/apps/encryption/tests/Crypto/DecryptAllTest.php index 83684b8be32..82e6100bce5 100644 --- a/apps/encryption/tests/Crypto/DecryptAllTest.php +++ b/apps/encryption/tests/Crypto/DecryptAllTest.php @@ -59,11 +59,11 @@ class DecryptAllTest extends TestCase { } /** - * @dataProvider dataTestGetPrivateKey * * @param string $user * @param string $recoveryKeyId */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetPrivateKey')] public function testGetPrivateKey($user, $recoveryKeyId, $masterKeyId): void { $password = 'passwd'; $recoveryKey = 'recoveryKey'; diff --git a/apps/encryption/tests/Crypto/EncryptAllTest.php b/apps/encryption/tests/Crypto/EncryptAllTest.php index 45743ae733b..6dbbd55df78 100644 --- a/apps/encryption/tests/Crypto/EncryptAllTest.php +++ b/apps/encryption/tests/Crypto/EncryptAllTest.php @@ -249,7 +249,7 @@ class EncryptAllTest extends TestCase { $encryptAllCalls = []; $encryptAll->expects($this->exactly(2)) ->method('encryptUsersFiles') - ->willReturnCallback(function ($uid) use (&$encryptAllCalls) { + ->willReturnCallback(function ($uid) use (&$encryptAllCalls): void { $encryptAllCalls[] = $uid; }); @@ -317,7 +317,7 @@ class EncryptAllTest extends TestCase { $encryptAllCalls = []; $encryptAll->expects($this->exactly(2)) ->method('encryptFile') - ->willReturnCallback(function (string $path) use (&$encryptAllCalls) { + ->willReturnCallback(function (string $path) use (&$encryptAllCalls): void { $encryptAllCalls[] = $path; }); @@ -346,9 +346,9 @@ class EncryptAllTest extends TestCase { } /** - * @dataProvider dataTestEncryptFile * @param $isEncrypted */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestEncryptFile')] public function testEncryptFile($isEncrypted): void { $fileInfo = $this->createMock(FileInfo::class); $fileInfo->expects($this->any())->method('isEncrypted') diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php index 999c6242f0c..37e484550ef 100644 --- a/apps/encryption/tests/Crypto/EncryptionTest.php +++ b/apps/encryption/tests/Crypto/EncryptionTest.php @@ -152,9 +152,7 @@ class EncryptionTest extends TestCase { return $publicKeys; } - /** - * @dataProvider dataProviderForTestGetPathToRealFile - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataProviderForTestGetPathToRealFile')] public function testGetPathToRealFile($path, $expected): void { $this->assertSame($expected, self::invokePrivate($this->instance, 'getPathToRealFile', [$path]) @@ -170,9 +168,7 @@ class EncryptionTest extends TestCase { ]; } - /** - * @dataProvider dataTestBegin - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestBegin')] public function testBegin($mode, $header, $legacyCipher, $defaultCipher, $fileKey, $expected): void { $this->sessionMock->expects($this->once()) ->method('decryptAllModeActivated') @@ -265,11 +261,11 @@ class EncryptionTest extends TestCase { } /** - * @dataProvider dataTestUpdate * * @param string $fileKey * @param boolean $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestUpdate')] public function testUpdate($fileKey, $expected): void { $this->keyManagerMock->expects($this->once()) ->method('getFileKey')->willReturn($fileKey); @@ -354,9 +350,8 @@ class EncryptionTest extends TestCase { /** * by default the encryption module should encrypt regular files, files in * files_versions and files in files_trashbin - * - * @dataProvider dataTestShouldEncrypt */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestShouldEncrypt')] public function testShouldEncrypt($path, $shouldEncryptHomeStorage, $isHomeStorage, $expected): void { $this->utilMock->expects($this->once())->method('shouldEncryptHomeStorage') ->willReturn($shouldEncryptHomeStorage); diff --git a/apps/encryption/tests/KeyManagerTest.php b/apps/encryption/tests/KeyManagerTest.php index 187c21bc687..3fe76fc4f59 100644 --- a/apps/encryption/tests/KeyManagerTest.php +++ b/apps/encryption/tests/KeyManagerTest.php @@ -166,9 +166,7 @@ class KeyManagerTest extends TestCase { ); } - /** - * @dataProvider dataTestUserHasKeys - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestUserHasKeys')] public function testUserHasKeys($key, $expected): void { $this->keyStorageMock->expects($this->exactly(2)) ->method('getUserKey') @@ -221,10 +219,9 @@ class KeyManagerTest extends TestCase { } /** - * @dataProvider dataTestInit - * * @param bool $useMasterKey */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestInit')] public function testInit($useMasterKey): void { /** @var KeyManager&MockObject $instance */ $instance = $this->getMockBuilder(KeyManager::class) @@ -248,7 +245,7 @@ class KeyManagerTest extends TestCase { $sessionSetStatusCalls = []; $this->sessionMock->expects($this->exactly(2)) ->method('setStatus') - ->willReturnCallback(function (string $status) use (&$sessionSetStatusCalls) { + ->willReturnCallback(function (string $status) use (&$sessionSetStatusCalls): void { $sessionSetStatusCalls[] = $status; }); @@ -356,13 +353,13 @@ class KeyManagerTest extends TestCase { } /** - * @dataProvider dataTestGetFileKey * * @param $uid * @param $isMasterKeyEnabled * @param $privateKey * @param $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetFileKey')] public function testGetFileKey($uid, $isMasterKeyEnabled, $privateKey, $encryptedFileKey, $expected): void { $path = '/foo.txt'; @@ -452,13 +449,13 @@ class KeyManagerTest extends TestCase { /** * test add public share key and or recovery key to the list of public keys * - * @dataProvider dataTestAddSystemKeys * * @param array $accessList * @param array $publicKeys * @param string $uid * @param array $expectedKeys */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestAddSystemKeys')] public function testAddSystemKeys($accessList, $publicKeys, $uid, $expectedKeys): void { $publicShareKeyId = 'publicShareKey'; $recoveryKeyId = 'recoveryKey'; @@ -539,10 +536,9 @@ class KeyManagerTest extends TestCase { } /** - * @dataProvider dataTestValidateMasterKey - * * @param $masterKey */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestValidateMasterKey')] public function testValidateMasterKey($masterKey): void { /** @var KeyManager&MockObject $instance */ $instance = $this->getMockBuilder(KeyManager::class) diff --git a/apps/encryption/tests/SessionTest.php b/apps/encryption/tests/SessionTest.php index 9e38f857e73..986502749c8 100644 --- a/apps/encryption/tests/SessionTest.php +++ b/apps/encryption/tests/SessionTest.php @@ -115,11 +115,11 @@ class SessionTest extends TestCase { } /** - * @dataProvider dataTestIsReady * * @param int $status * @param bool $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestIsReady')] public function testIsReady($status, $expected): void { /** @var Session&MockObject $instance */ $instance = $this->getMockBuilder(Session::class) diff --git a/apps/encryption/tests/Settings/AdminTest.php b/apps/encryption/tests/Settings/AdminTest.php index 5ae9e7eb3c6..8355cdf6729 100644 --- a/apps/encryption/tests/Settings/AdminTest.php +++ b/apps/encryption/tests/Settings/AdminTest.php @@ -53,7 +53,7 @@ class AdminTest extends TestCase { public function testGetForm(): void { $this->config ->method('getAppValue') - ->will($this->returnCallback(function ($app, $key, $default) { + ->willReturnCallback(function ($app, $key, $default) { if ($app === 'encryption' && $key === 'recoveryAdminEnabled' && $default === '0') { return '1'; } @@ -61,7 +61,7 @@ class AdminTest extends TestCase { return '1'; } return $default; - })); + }); $params = [ 'recoveryEnabled' => '1', 'initStatus' => '0', diff --git a/apps/encryption/tests/Users/SetupTest.php b/apps/encryption/tests/Users/SetupTest.php index b2abfcba1db..6b2b8b4cad5 100644 --- a/apps/encryption/tests/Users/SetupTest.php +++ b/apps/encryption/tests/Users/SetupTest.php @@ -46,11 +46,11 @@ class SetupTest extends TestCase { } /** - * @dataProvider dataTestSetupUser * * @param bool $hasKeys * @param bool $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSetupUser')] public function testSetupUser($hasKeys, $expected): void { $this->keyManagerMock->expects($this->once())->method('userHasKeys') ->with('uid')->willReturn($hasKeys); diff --git a/apps/encryption/tests/UtilTest.php b/apps/encryption/tests/UtilTest.php index 3556b9e34c1..41860a44ffb 100644 --- a/apps/encryption/tests/UtilTest.php +++ b/apps/encryption/tests/UtilTest.php @@ -115,11 +115,11 @@ class UtilTest extends TestCase { } /** - * @dataProvider dataTestIsMasterKeyEnabled * * @param string $value * @param bool $expect */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestIsMasterKeyEnabled')] public function testIsMasterKeyEnabled($value, $expect): void { $this->configMock->expects($this->once())->method('getAppValue') ->with('encryption', 'useMasterKey', '1')->willReturn($value); @@ -136,10 +136,10 @@ class UtilTest extends TestCase { } /** - * @dataProvider dataTestShouldEncryptHomeStorage * @param string $returnValue return value from getAppValue() * @param bool $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestShouldEncryptHomeStorage')] public function testShouldEncryptHomeStorage($returnValue, $expected): void { $this->configMock->expects($this->once())->method('getAppValue') ->with('encryption', 'encryptHomeStorage', '1') @@ -157,10 +157,10 @@ class UtilTest extends TestCase { } /** - * @dataProvider dataTestSetEncryptHomeStorage * @param $value * @param $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSetEncryptHomeStorage')] public function testSetEncryptHomeStorage($value, $expected): void { $this->configMock->expects($this->once())->method('setAppValue') ->with('encryption', 'encryptHomeStorage', $expected); diff --git a/apps/federatedfilesharing/tests/AddressHandlerTest.php b/apps/federatedfilesharing/tests/AddressHandlerTest.php index 232ac21a869..9b67e3e1848 100644 --- a/apps/federatedfilesharing/tests/AddressHandlerTest.php +++ b/apps/federatedfilesharing/tests/AddressHandlerTest.php @@ -80,9 +80,7 @@ class AddressHandlerTest extends \Test\TestCase { return $testCases; } - /** - * @dataProvider dataTestSplitUserRemote - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSplitUserRemote')] public function testSplitUserRemote(string $remote, string $expectedUser, string $expectedUrl): void { $this->contactsManager->expects($this->any()) ->method('search') @@ -111,18 +109,14 @@ class AddressHandlerTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataTestSplitUserRemoteError - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSplitUserRemoteError')] public function testSplitUserRemoteError(string $id): void { $this->expectException(HintException::class); $this->addressHandler->splitUserRemote($id); } - /** - * @dataProvider dataTestCompareAddresses - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestCompareAddresses')] public function testCompareAddresses(string $user1, string $server1, string $user2, string $server2, bool $expected): void { $this->assertSame($expected, $this->addressHandler->compareAddresses($user1, $server1, $user2, $server2) @@ -149,9 +143,7 @@ class AddressHandlerTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataTestRemoveProtocolFromUrl - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestRemoveProtocolFromUrl')] public function testRemoveProtocolFromUrl(string $url, string $expectedResult): void { $result = $this->addressHandler->removeProtocolFromUrl($url); $this->assertSame($expectedResult, $result); @@ -165,9 +157,7 @@ class AddressHandlerTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataTestUrlContainProtocol - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestUrlContainProtocol')] public function testUrlContainProtocol(string $url, bool $expectedResult): void { $result = $this->addressHandler->urlContainProtocol($url); $this->assertSame($expectedResult, $result); diff --git a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php index a6c10148425..cb890417d0b 100644 --- a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php +++ b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php @@ -85,9 +85,7 @@ class MountPublicLinkControllerTest extends \Test\TestCase { ); } - /** - * @dataProvider dataTestCreateFederatedShare - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestCreateFederatedShare')] public function testCreateFederatedShare( string $shareWith, bool $outgoingSharesAllowed, diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php index fc6dbf7a699..4d6add962fe 100644 --- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php +++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php @@ -117,9 +117,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataTestCreate - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestCreate')] public function testCreate(?\DateTime $expirationDate, ?string $expectedDataDate): void { $share = $this->shareManager->newShare(); @@ -419,9 +417,7 @@ class FederatedShareProviderTest extends \Test\TestCase { } } - /** - * @dataProvider dataTestUpdate - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestUpdate')] public function testUpdate(string $owner, string $sharedBy, ?\DateTime $expirationDate): void { $this->provider = $this->getMockBuilder(FederatedShareProvider::class) ->setConstructorArgs( @@ -705,7 +701,6 @@ class FederatedShareProviderTest extends \Test\TestCase { } /** - * @dataProvider dataDeleteUser * * @param string $owner The owner of the share (uid) * @param string $initiator The initiator of the share (uid) @@ -713,6 +708,7 @@ class FederatedShareProviderTest extends \Test\TestCase { * @param string $deletedUser The user that is deleted * @param bool $rowDeleted Is the row deleted in this setup */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataDeleteUser')] public function testDeleteUser(string $owner, string $initiator, string $recipient, string $deletedUser, bool $rowDeleted): void { $qb = $this->connection->getQueryBuilder(); $qb->insert('share') @@ -742,9 +738,7 @@ class FederatedShareProviderTest extends \Test\TestCase { $this->assertCount($rowDeleted ? 0 : 1, $data); } - /** - * @dataProvider dataTestIsOutgoingServer2serverShareEnabled - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestIsOutgoingServer2serverShareEnabled')] public function testIsOutgoingServer2serverShareEnabled(bool $internalOnly, string $isEnabled, bool $expected): void { $this->gsConfig->expects($this->once())->method('onlyInternalFederation') ->willReturn($internalOnly); @@ -766,9 +760,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataTestIsIncomingServer2serverShareEnabled - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestIsIncomingServer2serverShareEnabled')] public function testIsIncomingServer2serverShareEnabled(bool $onlyInternal, string $isEnabled, bool $expected): void { $this->gsConfig->expects($this->once())->method('onlyInternalFederation') ->willReturn($onlyInternal); @@ -790,9 +782,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataTestIsLookupServerQueriesEnabled - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestIsLookupServerQueriesEnabled')] public function testIsLookupServerQueriesEnabled(bool $gsEnabled, string $isEnabled, bool $expected): void { $this->gsConfig->expects($this->once())->method('isGlobalScaleEnabled') ->willReturn($gsEnabled); @@ -818,9 +808,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataTestIsLookupServerUploadEnabled - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestIsLookupServerUploadEnabled')] public function testIsLookupServerUploadEnabled(bool $gsEnabled, string $isEnabled, bool $expected): void { $this->gsConfig->expects($this->once())->method('isGlobalScaleEnabled') ->willReturn($gsEnabled); diff --git a/apps/federatedfilesharing/tests/NotificationsTest.php b/apps/federatedfilesharing/tests/NotificationsTest.php index 94d08b5aa5d..da5defd8e55 100644 --- a/apps/federatedfilesharing/tests/NotificationsTest.php +++ b/apps/federatedfilesharing/tests/NotificationsTest.php @@ -78,9 +78,7 @@ class NotificationsTest extends \Test\TestCase { } - /** - * @dataProvider dataTestSendUpdateToRemote - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSendUpdateToRemote')] public function testSendUpdateToRemote(int $try, array $httpRequestResult, bool $expected): void { $remote = 'http://remote'; $id = 42; diff --git a/apps/federatedfilesharing/tests/Settings/AdminTest.php b/apps/federatedfilesharing/tests/Settings/AdminTest.php index 1eb75003b4f..1eee362c11f 100644 --- a/apps/federatedfilesharing/tests/Settings/AdminTest.php +++ b/apps/federatedfilesharing/tests/Settings/AdminTest.php @@ -53,9 +53,7 @@ class AdminTest extends TestCase { ]; } - /** - * @dataProvider sharingStateProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('sharingStateProvider')] public function testGetForm(bool $state): void { $this->federatedShareProvider ->expects($this->once()) @@ -110,7 +108,7 @@ class AdminTest extends TestCase { ]; $this->initialState->expects($this->exactly(10)) ->method('provideInitialState') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertSame($expected, func_get_args()); }); diff --git a/apps/federatedfilesharing/tests/TestCase.php b/apps/federatedfilesharing/tests/TestCase.php index 1536e1b3375..50f01eb5e62 100644 --- a/apps/federatedfilesharing/tests/TestCase.php +++ b/apps/federatedfilesharing/tests/TestCase.php @@ -93,7 +93,7 @@ abstract class TestCase extends \Test\TestCase { Server::get(IUserSession::class)->setUser(null); Filesystem::tearDown(); Server::get(IUserSession::class)->login($user, $password); - \OCP\Server::get(IRootFolder::class)->getUserFolder($user); + Server::get(IRootFolder::class)->getUserFolder($user); \OC_Util::setupFS($user); } diff --git a/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php b/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php index 017a33b4941..943bdf352de 100644 --- a/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php +++ b/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php @@ -76,9 +76,7 @@ class GetSharedSecretTest extends TestCase { ); } - /** - * @dataProvider dataTestExecute - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestExecute')] public function testExecute(bool $isTrustedServer, bool $retainBackgroundJob): void { /** @var GetSharedSecret&MockObject $getSharedSecret */ $getSharedSecret = $this->getMockBuilder(GetSharedSecret::class) @@ -136,9 +134,7 @@ class GetSharedSecretTest extends TestCase { ]; } - /** - * @dataProvider dataTestRun - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestRun')] public function testRun(int $statusCode): void { $target = 'targetURL'; $source = 'sourceURL'; diff --git a/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php b/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php index 8aa83df0b0d..6ef579c7483 100644 --- a/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php +++ b/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php @@ -66,9 +66,7 @@ class RequestSharedSecretTest extends TestCase { ); } - /** - * @dataProvider dataTestStart - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestStart')] public function testStart(bool $isTrustedServer, bool $retainBackgroundJob): void { /** @var RequestSharedSecret&MockObject $requestSharedSecret */ $requestSharedSecret = $this->getMockBuilder(RequestSharedSecret::class) @@ -127,9 +125,7 @@ class RequestSharedSecretTest extends TestCase { ]; } - /** - * @dataProvider dataTestRun - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestRun')] public function testRun(int $statusCode, int $attempt = 0): void { $target = 'targetURL'; $source = 'sourceURL'; diff --git a/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php b/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php index 25b0db94e21..a054277c5cd 100644 --- a/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php +++ b/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php @@ -64,9 +64,7 @@ class OCSAuthAPIControllerTest extends TestCase { ->willReturn($this->currentTime); } - /** - * @dataProvider dataTestRequestSharedSecret - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestRequestSharedSecret')] public function testRequestSharedSecret(string $token, string $localToken, bool $isTrustedServer, bool $ok): void { $url = 'url'; @@ -106,9 +104,7 @@ class OCSAuthAPIControllerTest extends TestCase { ]; } - /** - * @dataProvider dataTestGetSharedSecret - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetSharedSecret')] public function testGetSharedSecret(bool $isTrustedServer, bool $isValidToken, bool $ok): void { $url = 'url'; $token = 'token'; diff --git a/apps/federation/tests/Controller/SettingsControllerTest.php b/apps/federation/tests/Controller/SettingsControllerTest.php index d88f397da34..b0a7a5e30c9 100644 --- a/apps/federation/tests/Controller/SettingsControllerTest.php +++ b/apps/federation/tests/Controller/SettingsControllerTest.php @@ -65,9 +65,7 @@ class SettingsControllerTest extends TestCase { $this->assertArrayHasKey('id', $data); } - /** - * @dataProvider checkServerFails - */ + #[\PHPUnit\Framework\Attributes\DataProvider('checkServerFails')] public function testAddServerFail(bool $isTrustedServer, bool $isNextcloud): void { $this->trustedServers ->expects($this->any()) @@ -115,9 +113,7 @@ class SettingsControllerTest extends TestCase { ); } - /** - * @dataProvider checkServerFails - */ + #[\PHPUnit\Framework\Attributes\DataProvider('checkServerFails')] public function testCheckServerFail(bool $isTrustedServer, bool $isNextcloud): void { $this->trustedServers ->expects($this->any()) diff --git a/apps/federation/tests/DAV/FedAuthTest.php b/apps/federation/tests/DAV/FedAuthTest.php index c49e6f7e86f..c95d3852b48 100644 --- a/apps/federation/tests/DAV/FedAuthTest.php +++ b/apps/federation/tests/DAV/FedAuthTest.php @@ -15,9 +15,7 @@ use Test\TestCase; class FedAuthTest extends TestCase { - /** - * @dataProvider providesUser - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesUser')] public function testFedAuth(bool $expected, string $user, string $password): void { /** @var DbHandler&MockObject $db */ $db = $this->createMock(DbHandler::class); diff --git a/apps/federation/tests/DbHandlerTest.php b/apps/federation/tests/DbHandlerTest.php index a9abdbf776c..5452a48fc4a 100644 --- a/apps/federation/tests/DbHandlerTest.php +++ b/apps/federation/tests/DbHandlerTest.php @@ -52,12 +52,12 @@ class DbHandlerTest extends TestCase { } /** - * @dataProvider dataTestAddServer * * @param string $url passed to the method * @param string $expectedUrl the url we expect to be written to the db * @param string $expectedHash the hash value we expect to be written to the db */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestAddServer')] public function testAddServer(string $url, string $expectedUrl, string $expectedHash): void { $id = $this->dbHandler->addServer($url); @@ -128,9 +128,7 @@ class DbHandlerTest extends TestCase { $this->assertSame($id2, (int)$result[1]['id']); } - /** - * @dataProvider dataTestServerExists - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestServerExists')] public function testServerExists(string $serverInTable, string $checkForServer, bool $expected): void { $this->dbHandler->addServer($serverInTable); $this->assertSame($expected, @@ -234,9 +232,8 @@ class DbHandlerTest extends TestCase { /** * hash should always be computed with the normalized URL - * - * @dataProvider dataTestHash */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestHash')] public function testHash(string $url, string $expected): void { $this->assertSame($expected, $this->invokePrivate($this->dbHandler, 'hash', [$url]) @@ -252,9 +249,7 @@ class DbHandlerTest extends TestCase { ]; } - /** - * @dataProvider dataTestNormalizeUrl - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestNormalizeUrl')] public function testNormalizeUrl(string $url, string $expected): void { $this->assertSame($expected, $this->invokePrivate($this->dbHandler, 'normalizeUrl', [$url]) @@ -271,9 +266,7 @@ class DbHandlerTest extends TestCase { ]; } - /** - * @dataProvider providesAuth - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesAuth')] public function testAuth(bool $expectedResult, string $user, string $password): void { if ($expectedResult) { $this->dbHandler->addServer('url1'); diff --git a/apps/federation/tests/Settings/AdminTest.php b/apps/federation/tests/Settings/AdminTest.php index b4c7121c5c9..b879547a8cd 100644 --- a/apps/federation/tests/Settings/AdminTest.php +++ b/apps/federation/tests/Settings/AdminTest.php @@ -20,7 +20,7 @@ class AdminTest extends TestCase { protected function setUp(): void { parent::setUp(); - $this->trustedServers = $this->createMock(\OCA\Federation\TrustedServers::class); + $this->trustedServers = $this->createMock(TrustedServers::class); $this->admin = new Admin( $this->trustedServers, $this->createMock(IL10N::class) diff --git a/apps/federation/tests/TrustedServersTest.php b/apps/federation/tests/TrustedServersTest.php index 4d64df7a5e1..c8477f637cb 100644 --- a/apps/federation/tests/TrustedServersTest.php +++ b/apps/federation/tests/TrustedServersTest.php @@ -170,9 +170,7 @@ class TrustedServersTest extends TestCase { ); } - /** - * @dataProvider dataTestIsNextcloudServer - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestIsNextcloudServer')] public function testIsNextcloudServer(int $statusCode, bool $isValidNextcloudVersion, bool $expected): void { $server = 'server1'; @@ -239,9 +237,7 @@ class TrustedServersTest extends TestCase { $this->assertFalse($this->trustedServers->isNextcloudServer($server)); } - /** - * @dataProvider dataTestCheckNextcloudVersion - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestCheckNextcloudVersion')] public function testCheckNextcloudVersion(string $status): void { $this->assertTrue(self::invokePrivate($this->trustedServers, 'checkNextcloudVersion', [$status])); } @@ -253,9 +249,7 @@ class TrustedServersTest extends TestCase { ]; } - /** - * @dataProvider dataTestCheckNextcloudVersionTooLow - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestCheckNextcloudVersionTooLow')] public function testCheckNextcloudVersionTooLow(string $status): void { $this->expectException(HintException::class); $this->expectExceptionMessage('Remote server version is too low. 9.0 is required.'); @@ -269,9 +263,7 @@ class TrustedServersTest extends TestCase { ]; } - /** - * @dataProvider dataTestUpdateProtocol - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestUpdateProtocol')] public function testUpdateProtocol(string $url, string $expected): void { $this->assertSame($expected, self::invokePrivate($this->trustedServers, 'updateProtocol', [$url]) diff --git a/apps/files/tests/Activity/Filter/GenericTest.php b/apps/files/tests/Activity/Filter/GenericTest.php index f37a1cb2c9e..40e2f9848b5 100644 --- a/apps/files/tests/Activity/Filter/GenericTest.php +++ b/apps/files/tests/Activity/Filter/GenericTest.php @@ -27,35 +27,27 @@ class GenericTest extends TestCase { ]; } - /** - * @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); @@ -65,9 +57,7 @@ class GenericTest extends TestCase { $this->assertLessThanOrEqual(100, $priority); } - /** - * @dataProvider dataFilters - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataFilters')] public function testGetIcon(string $filterClass): void { /** @var IFilter $filter */ $filter = Server::get($filterClass); @@ -75,18 +65,14 @@ class GenericTest extends TestCase { $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); diff --git a/apps/files/tests/Activity/ProviderTest.php b/apps/files/tests/Activity/ProviderTest.php index ed52c76ba28..b6ba095ecfe 100644 --- a/apps/files/tests/Activity/ProviderTest.php +++ b/apps/files/tests/Activity/ProviderTest.php @@ -90,9 +90,7 @@ class ProviderTest extends TestCase { ]; } - /** - * @dataProvider dataGetFile - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetFile')] public function testGetFile(array|string $parameter, ?int $eventId, string $id, string $name, string $path): void { $provider = $this->getProvider(); @@ -136,9 +134,7 @@ class ProviderTest extends TestCase { ]; } - /** - * @dataProvider dataGetUser - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetUser')] public function testGetUser(string $uid, ?string $userDisplayName, ?array $cloudIdData, array $expected): void { $provider = $this->getProvider(); diff --git a/apps/files/tests/Activity/Setting/GenericTest.php b/apps/files/tests/Activity/Setting/GenericTest.php index 7e549ce9dc0..df6b1e0f6d4 100644 --- a/apps/files/tests/Activity/Setting/GenericTest.php +++ b/apps/files/tests/Activity/Setting/GenericTest.php @@ -22,35 +22,27 @@ class GenericTest extends TestCase { ]; } - /** - * @dataProvider dataSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] public function testImplementsInterface(string $settingClass): void { $setting = Server::get($settingClass); $this->assertInstanceOf(ISetting::class, $setting); } - /** - * @dataProvider dataSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] public function testGetIdentifier(string $settingClass): void { /** @var ISetting $setting */ $setting = Server::get($settingClass); $this->assertIsString($setting->getIdentifier()); } - /** - * @dataProvider dataSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] public function testGetName(string $settingClass): void { /** @var ISetting $setting */ $setting = Server::get($settingClass); $this->assertIsString($setting->getName()); } - /** - * @dataProvider dataSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] public function testGetPriority(string $settingClass): void { /** @var ISetting $setting */ $setting = Server::get($settingClass); @@ -60,36 +52,28 @@ class GenericTest extends TestCase { $this->assertLessThanOrEqual(100, $priority); } - /** - * @dataProvider dataSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] public function testCanChangeStream(string $settingClass): void { /** @var ISetting $setting */ $setting = Server::get($settingClass); $this->assertIsBool($setting->canChangeStream()); } - /** - * @dataProvider dataSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] public function testIsDefaultEnabledStream(string $settingClass): void { /** @var ISetting $setting */ $setting = Server::get($settingClass); $this->assertIsBool($setting->isDefaultEnabledStream()); } - /** - * @dataProvider dataSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] public function testCanChangeMail(string $settingClass): void { /** @var ISetting $setting */ $setting = Server::get($settingClass); $this->assertIsBool($setting->canChangeMail()); } - /** - * @dataProvider dataSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] public function testIsDefaultEnabledMail(string $settingClass): void { /** @var ISetting $setting */ $setting = Server::get($settingClass); diff --git a/apps/files/tests/AdvancedCapabilitiesTest.php b/apps/files/tests/AdvancedCapabilitiesTest.php index 8f4a845b708..f39ac1c873f 100644 --- a/apps/files/tests/AdvancedCapabilitiesTest.php +++ b/apps/files/tests/AdvancedCapabilitiesTest.php @@ -23,9 +23,7 @@ class AdvancedCapabilitiesTest extends TestCase { $this->capabilities = new AdvancedCapabilities($this->service); } - /** - * @dataProvider dataGetCapabilities - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetCapabilities')] public function testGetCapabilities(bool $wcf): void { $this->service ->expects(self::once()) diff --git a/apps/files/tests/Command/DeleteOrphanedFilesTest.php b/apps/files/tests/Command/DeleteOrphanedFilesTest.php index 54b5ac6c12f..a488915e0cb 100644 --- a/apps/files/tests/Command/DeleteOrphanedFilesTest.php +++ b/apps/files/tests/Command/DeleteOrphanedFilesTest.php @@ -117,7 +117,7 @@ class DeleteOrphanedFilesTest extends TestCase { $output ->expects($this->exactly(3)) ->method('writeln') - ->willReturnCallback(function (string $message) use (&$calls) { + ->willReturnCallback(function (string $message) use (&$calls): void { $expected = array_shift($calls); $this->assertSame($expected, $message); }); diff --git a/apps/files/tests/Controller/ApiControllerTest.php b/apps/files/tests/Controller/ApiControllerTest.php index d6d86e293fd..e74989eb2f5 100644 --- a/apps/files/tests/Controller/ApiControllerTest.php +++ b/apps/files/tests/Controller/ApiControllerTest.php @@ -119,7 +119,7 @@ class ApiControllerTest extends TestCase { $this->tagService->expects($this->once()) ->method('updateFileTags') ->with('/path.txt', ['Tag1', 'Tag2']) - ->will($this->throwException(new NotFoundException('My error message'))); + ->willThrowException(new NotFoundException('My error message')); $expected = new DataResponse(['message' => 'My error message'], Http::STATUS_NOT_FOUND); $this->assertEquals($expected, $this->apiController->updateFileTags('/path.txt', ['Tag1', 'Tag2'])); @@ -129,7 +129,7 @@ class ApiControllerTest extends TestCase { $this->tagService->expects($this->once()) ->method('updateFileTags') ->with('/path.txt', ['Tag1', 'Tag2']) - ->will($this->throwException(new StorageNotAvailableException('My error message'))); + ->willThrowException(new StorageNotAvailableException('My error message')); $expected = new DataResponse(['message' => 'My error message'], Http::STATUS_SERVICE_UNAVAILABLE); $this->assertEquals($expected, $this->apiController->updateFileTags('/path.txt', ['Tag1', 'Tag2'])); @@ -139,7 +139,7 @@ class ApiControllerTest extends TestCase { $this->tagService->expects($this->once()) ->method('updateFileTags') ->with('/path.txt', ['Tag1', 'Tag2']) - ->will($this->throwException(new \Exception('My error message'))); + ->willThrowException(new \Exception('My error message')); $expected = new DataResponse(['message' => 'My error message'], Http::STATUS_NOT_FOUND); $this->assertEquals($expected, $this->apiController->updateFileTags('/path.txt', ['Tag1', 'Tag2'])); diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php index 93ef98bdec7..a9a80fc6f35 100644 --- a/apps/files/tests/Controller/ViewControllerTest.php +++ b/apps/files/tests/Controller/ViewControllerTest.php @@ -210,9 +210,7 @@ class ViewControllerTest extends TestCase { ]; } - /** - * @dataProvider dataTestShortRedirect - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestShortRedirect')] public function testShortRedirect(?string $openfile, ?string $opendetails, string $result): void { $this->appManager->expects($this->any()) ->method('isEnabledForUser') diff --git a/apps/files/tests/HelperTest.php b/apps/files/tests/HelperTest.php index cb1fc5ed66d..ba93fa0efdf 100644 --- a/apps/files/tests/HelperTest.php +++ b/apps/files/tests/HelperTest.php @@ -76,9 +76,7 @@ class HelperTest extends \Test\TestCase { ]; } - /** - * @dataProvider sortDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('sortDataProvider')] public function testSortByName(string $sort, bool $sortDescending, array $expectedOrder): void { if (($sort === 'mtime') && (PHP_INT_SIZE < 8)) { $this->markTestSkipped('Skip mtime sorting on 32bit'); diff --git a/apps/files/tests/Service/TagServiceTest.php b/apps/files/tests/Service/TagServiceTest.php index 74e58e674bb..424e483102c 100644 --- a/apps/files/tests/Service/TagServiceTest.php +++ b/apps/files/tests/Service/TagServiceTest.php @@ -53,7 +53,7 @@ class TagServiceTest extends \Test\TestCase { ->withAnyParameters() ->willReturn($user); - $this->root = \OCP\Server::get(IRootFolder::class)->getUserFolder($this->user); + $this->root = Server::get(IRootFolder::class)->getUserFolder($this->user); $this->tagger = Server::get(ITagManager::class)->load('files'); $this->tagService = $this->getTagService(); diff --git a/apps/files_external/tests/Auth/AuthMechanismTest.php b/apps/files_external/tests/Auth/AuthMechanismTest.php index d6279ea4f1f..e999cecf181 100644 --- a/apps/files_external/tests/Auth/AuthMechanismTest.php +++ b/apps/files_external/tests/Auth/AuthMechanismTest.php @@ -37,9 +37,7 @@ class AuthMechanismTest extends \Test\TestCase { ]; } - /** - * @dataProvider validateStorageProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('validateStorageProvider')] public function testValidateStorage(bool $expectedSuccess, string $scheme, bool $definitionSuccess): void { $mechanism = $this->getMockBuilder(AuthMechanism::class) ->onlyMethods(['validateStorageDefinition']) diff --git a/apps/files_external/tests/Auth/Password/GlobalAuthTest.php b/apps/files_external/tests/Auth/Password/GlobalAuthTest.php index 02f15cb76c4..6d83655403e 100644 --- a/apps/files_external/tests/Auth/Password/GlobalAuthTest.php +++ b/apps/files_external/tests/Auth/Password/GlobalAuthTest.php @@ -29,7 +29,7 @@ class GlobalAuthTest extends TestCase { } private function getStorageConfig($type, $config = []) { - /** @var \OCA\Files_External\Lib\StorageConfig&MockObject $storageConfig */ + /** @var StorageConfig&MockObject $storageConfig */ $storageConfig = $this->createMock(StorageConfig::class); $storageConfig->expects($this->any()) ->method('getType') diff --git a/apps/files_external/tests/Backend/BackendTest.php b/apps/files_external/tests/Backend/BackendTest.php index 1e158654595..1653c354e16 100644 --- a/apps/files_external/tests/Backend/BackendTest.php +++ b/apps/files_external/tests/Backend/BackendTest.php @@ -41,9 +41,7 @@ class BackendTest extends \Test\TestCase { ]; } - /** - * @dataProvider validateStorageProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('validateStorageProvider')] public function testValidateStorage(bool $expectedSuccess, bool $definitionSuccess): void { $backend = $this->getMockBuilder(Backend::class) ->onlyMethods(['validateStorageDefinition']) diff --git a/apps/files_external/tests/Config/UserPlaceholderHandlerTest.php b/apps/files_external/tests/Config/UserPlaceholderHandlerTest.php index b40e9461287..13d25ce5075 100644 --- a/apps/files_external/tests/Config/UserPlaceholderHandlerTest.php +++ b/apps/files_external/tests/Config/UserPlaceholderHandlerTest.php @@ -53,17 +53,13 @@ class UserPlaceholderHandlerTest extends \Test\TestCase { ]; } - /** - * @dataProvider optionProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('optionProvider')] public function testHandle(string|array $option, string|array $expected): void { $this->setUser(); $this->assertSame($expected, $this->handler->handle($option)); } - /** - * @dataProvider optionProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('optionProvider')] public function testHandleNoUser(string|array $option): void { $this->shareManager->expects($this->once()) ->method('getShareByToken') diff --git a/apps/files_external/tests/Controller/StoragesControllerTestCase.php b/apps/files_external/tests/Controller/StoragesControllerTestCase.php index bb29904ab0d..1eb52f9b459 100644 --- a/apps/files_external/tests/Controller/StoragesControllerTestCase.php +++ b/apps/files_external/tests/Controller/StoragesControllerTestCase.php @@ -186,9 +186,7 @@ abstract class StoragesControllerTestCase extends \Test\TestCase { ]; } - /** - * @dataProvider mountPointNamesProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('mountPointNamesProvider')] public function testAddOrUpdateStorageInvalidMountPoint($mountPoint): void { $storageConfig = new StorageConfig(1); $storageConfig->setMountPoint($mountPoint); @@ -235,7 +233,7 @@ abstract class StoragesControllerTestCase extends \Test\TestCase { public function testAddOrUpdateStorageInvalidBackend(): void { $this->service->expects($this->exactly(2)) ->method('createStorage') - ->will($this->throwException(new \InvalidArgumentException())); + ->willThrowException(new \InvalidArgumentException()); $this->service->expects($this->never()) ->method('addStorage'); $this->service->expects($this->never()) @@ -292,7 +290,7 @@ abstract class StoragesControllerTestCase extends \Test\TestCase { ->willReturn($storageConfig); $this->service->expects($this->once()) ->method('updateStorage') - ->will($this->throwException(new NotFoundException())); + ->willThrowException(new NotFoundException()); $response = $this->controller->update( 255, @@ -320,7 +318,7 @@ abstract class StoragesControllerTestCase extends \Test\TestCase { public function testDeleteStorageNonExisting(): void { $this->service->expects($this->once()) ->method('removeStorage') - ->will($this->throwException(new NotFoundException())); + ->willThrowException(new NotFoundException()); $response = $this->controller->destroy(255); $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus()); @@ -357,9 +355,7 @@ abstract class StoragesControllerTestCase extends \Test\TestCase { ]; } - /** - * @dataProvider validateStorageProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('validateStorageProvider')] public function testValidateStorage(bool $backendValidate, bool $authMechValidate, bool $expectSuccess): void { $backend = $this->getBackendMock(); $backend->method('validateStorage') diff --git a/apps/files_external/tests/DefinitionParameterTest.php b/apps/files_external/tests/DefinitionParameterTest.php index f39ba90c871..c535481bf66 100644 --- a/apps/files_external/tests/DefinitionParameterTest.php +++ b/apps/files_external/tests/DefinitionParameterTest.php @@ -68,9 +68,7 @@ class DefinitionParameterTest extends \Test\TestCase { ]; } - /** - * @dataProvider validateValueProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('validateValueProvider')] public function testValidateValue($type, $flags, $value, $success, $expectedValue = null): void { $param = new Param('foo', 'bar'); $param->setType($type); diff --git a/apps/files_external/tests/FrontendDefinitionTraitTest.php b/apps/files_external/tests/FrontendDefinitionTraitTest.php index 5319920e61a..e0bf066e70a 100644 --- a/apps/files_external/tests/FrontendDefinitionTraitTest.php +++ b/apps/files_external/tests/FrontendDefinitionTraitTest.php @@ -8,6 +8,7 @@ namespace OCA\Files_External\Tests; use OCA\Files_External\Lib\DefinitionParameter; +use OCA\Files_External\Lib\FrontendDefinitionTrait; use OCA\Files_External\Lib\StorageConfig; class FrontendDefinitionTraitTest extends \Test\TestCase { @@ -17,7 +18,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase { ->getMock(); $param->method('getName')->willReturn('foo'); - $trait = $this->getMockForTrait(\OCA\Files_External\Lib\FrontendDefinitionTrait::class); + $trait = $this->getMockForTrait(FrontendDefinitionTrait::class); $trait->setText('test'); $trait->addParameters([$param]); $trait->addCustomJs('foo/bar.js'); @@ -40,9 +41,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase { ]; } - /** - * @dataProvider validateStorageProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('validateStorageProvider')] public function testValidateStorage(bool $expectedSuccess, array $params): void { $backendParams = []; foreach ($params as $name => $valid) { @@ -68,7 +67,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase { $storageConfig->expects($this->any()) ->method('setBackendOption'); - $trait = $this->getMockForTrait(\OCA\Files_External\Lib\FrontendDefinitionTrait::class); + $trait = $this->getMockForTrait(FrontendDefinitionTrait::class); $trait->setText('test'); $trait->addParameters($backendParams); @@ -99,7 +98,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase { ->method('setBackendOption') ->with('param', 'foobar'); - $trait = $this->getMockForTrait(\OCA\Files_External\Lib\FrontendDefinitionTrait::class); + $trait = $this->getMockForTrait(FrontendDefinitionTrait::class); $trait->setText('test'); $trait->addParameter($param); diff --git a/apps/files_external/tests/LegacyDependencyCheckPolyfillTest.php b/apps/files_external/tests/LegacyDependencyCheckPolyfillTest.php index b6a351d44c0..d26aa752ea1 100644 --- a/apps/files_external/tests/LegacyDependencyCheckPolyfillTest.php +++ b/apps/files_external/tests/LegacyDependencyCheckPolyfillTest.php @@ -8,6 +8,7 @@ declare(strict_types=1); */ namespace OCA\Files_External\Tests; +use OCA\Files_External\Lib\LegacyDependencyCheckPolyfill; use OCA\Files_External\Lib\MissingDependency; class LegacyDependencyCheckPolyfillTest extends \Test\TestCase { @@ -23,7 +24,7 @@ class LegacyDependencyCheckPolyfillTest extends \Test\TestCase { } public function testCheckDependencies(): void { - $trait = $this->getMockForTrait(\OCA\Files_External\Lib\LegacyDependencyCheckPolyfill::class); + $trait = $this->getMockForTrait(LegacyDependencyCheckPolyfill::class); $trait->expects($this->once()) ->method('getStorageClass') ->willReturn(self::class); diff --git a/apps/files_external/tests/OwnCloudFunctionsTest.php b/apps/files_external/tests/OwnCloudFunctionsTest.php index 2890cad3ac1..2e052cb86b0 100644 --- a/apps/files_external/tests/OwnCloudFunctionsTest.php +++ b/apps/files_external/tests/OwnCloudFunctionsTest.php @@ -87,9 +87,7 @@ class OwnCloudFunctionsTest extends \Test\TestCase { ]; } - /** - * @dataProvider configUrlProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('configUrlProvider')] public function testConfig(array $config, string $expectedUri): void { $config['user'] = 'someuser'; $config['password'] = 'somepassword'; diff --git a/apps/files_external/tests/Service/BackendServiceTest.php b/apps/files_external/tests/Service/BackendServiceTest.php index a0426df10c8..ef545688040 100644 --- a/apps/files_external/tests/Service/BackendServiceTest.php +++ b/apps/files_external/tests/Service/BackendServiceTest.php @@ -208,9 +208,7 @@ class BackendServiceTest extends \Test\TestCase { ]; } - /** - * @dataProvider invalidConfigPlaceholderProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('invalidConfigPlaceholderProvider')] public function testRegisterConfigHandlerInvalid(array $placeholders): void { $this->expectException(\RuntimeException::class); diff --git a/apps/files_external/tests/Service/GlobalStoragesServiceTest.php b/apps/files_external/tests/Service/GlobalStoragesServiceTest.php index 47be54a02d4..0a3749981c8 100644 --- a/apps/files_external/tests/Service/GlobalStoragesServiceTest.php +++ b/apps/files_external/tests/Service/GlobalStoragesServiceTest.php @@ -115,9 +115,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTestCase { ]; } - /** - * @dataProvider storageDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('storageDataProvider')] public function testAddStorage($storageParams): void { $storage = $this->makeStorageConfig($storageParams); $newStorage = $this->service->addStorage($storage); @@ -139,9 +137,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTestCase { $this->assertEquals($baseId + 1, $nextStorage->getId()); } - /** - * @dataProvider storageDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('storageDataProvider')] public function testUpdateStorage($updatedStorageParams): void { $updatedStorage = $this->makeStorageConfig($updatedStorageParams); $storage = $this->makeStorageConfig([ @@ -281,9 +277,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTestCase { ]; } - /** - * @dataProvider hooksAddStorageDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('hooksAddStorageDataProvider')] public function testHooksAddStorage($applicableUsers, $applicableGroups, $expectedCalls): void { $storage = $this->makeTestStorageData(); $storage->setApplicableUsers($applicableUsers); @@ -419,9 +413,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTestCase { ]; } - /** - * @dataProvider hooksUpdateStorageDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('hooksUpdateStorageDataProvider')] public function testHooksUpdateStorage( array $sourceApplicableUsers, array $sourceApplicableGroups, @@ -579,9 +571,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTestCase { ]; } - /** - * @dataProvider hooksDeleteStorageDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('hooksDeleteStorageDataProvider')] public function testHooksDeleteStorage( array $sourceApplicableUsers, array $sourceApplicableGroups, diff --git a/apps/files_external/tests/Service/StoragesServiceTestCase.php b/apps/files_external/tests/Service/StoragesServiceTestCase.php index a5cffd45ec2..b41eb409468 100644 --- a/apps/files_external/tests/Service/StoragesServiceTestCase.php +++ b/apps/files_external/tests/Service/StoragesServiceTestCase.php @@ -250,9 +250,7 @@ abstract class StoragesServiceTestCase extends \Test\TestCase { ]; } - /** - * @dataProvider deleteStorageDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('deleteStorageDataProvider')] public function testDeleteStorage(array $backendOptions, string $rustyStorageId): void { $backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\DAV'); $authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism'); diff --git a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php index 6948d9d31bf..2a2f4596fda 100644 --- a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php +++ b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php @@ -98,9 +98,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { ]; } - /** - * @dataProvider applicableStorageProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('applicableStorageProvider')] public function testGetStorageWithApplicable($applicableUsers, $applicableGroups, $isVisible): void { $backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB'); $authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism'); @@ -174,9 +172,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { $this->ActualNonExistingStorageTest(); } - /** - * @dataProvider deleteStorageDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('deleteStorageDataProvider')] public function testDeleteStorage($backendOptions, $rustyStorageId): void { $this->expectException(\DomainException::class); @@ -230,9 +226,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { ]; } - /** - * @dataProvider getUniqueStoragesProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('getUniqueStoragesProvider')] public function testGetUniqueStorages( $priority1, $applicableUsers1, $applicableGroups1, $priority2, $applicableUsers2, $applicableGroups2, diff --git a/apps/files_external/tests/Service/UserStoragesServiceTest.php b/apps/files_external/tests/Service/UserStoragesServiceTest.php index 9dca0397f94..0a2f291f6e4 100644 --- a/apps/files_external/tests/Service/UserStoragesServiceTest.php +++ b/apps/files_external/tests/Service/UserStoragesServiceTest.php @@ -8,6 +8,7 @@ namespace OCA\Files_External\Tests\Service; use OC\Files\Filesystem; +use OC\User\User; use OCA\Files_External\Lib\StorageConfig; use OCA\Files_External\MountConfig; use OCA\Files_External\NotFoundException; @@ -27,7 +28,7 @@ use Test\Traits\UserTrait; class UserStoragesServiceTest extends StoragesServiceTestCase { use UserTrait; - protected \OC\User\User $user; + protected User $user; protected string $userId; protected StoragesService $globalStoragesService; @@ -127,9 +128,7 @@ class UserStoragesServiceTest extends StoragesServiceTestCase { $this->assertEmpty(self::$hookCalls); } - /** - * @dataProvider deleteStorageDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('deleteStorageDataProvider')] public function testDeleteStorage($backendOptions, $rustyStorageId): void { parent::testDeleteStorage($backendOptions, $rustyStorageId); diff --git a/apps/files_external/tests/Storage/SftpTest.php b/apps/files_external/tests/Storage/SftpTest.php index 082f0d7c502..ebfc8ab3c1f 100644 --- a/apps/files_external/tests/Storage/SftpTest.php +++ b/apps/files_external/tests/Storage/SftpTest.php @@ -46,9 +46,7 @@ class SftpTest extends \Test\Files\Storage\Storage { parent::tearDown(); } - /** - * @dataProvider configProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('configProvider')] public function testStorageId($config, $expectedStorageId): void { $instance = new SFTP($config); $this->assertEquals($expectedStorageId, $instance->getId()); diff --git a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php index c4cf09d6f03..f4a2cd500e1 100644 --- a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php +++ b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php @@ -8,6 +8,7 @@ declare(strict_types=1); */ namespace OCA\Files_Sharing\Controller; +use OCA\Deck\Sharing\ShareAPIHelper; use OCA\Files_Sharing\ResponseDefinitions; use OCP\App\IAppManager; use OCP\AppFramework\Http; @@ -210,7 +211,7 @@ class DeletedShareAPIController extends OCSController { * If the Deck application is not enabled or the helper is not available * a QueryException is thrown instead. * - * @return \OCA\Deck\Sharing\ShareAPIHelper + * @return ShareAPIHelper * @throws QueryException */ private function getDeckShareHelper() { @@ -227,7 +228,7 @@ class DeletedShareAPIController extends OCSController { * If the sciencemesh application is not enabled or the helper is not available * a QueryException is thrown instead. * - * @return \OCA\Deck\Sharing\ShareAPIHelper + * @return ShareAPIHelper * @throws QueryException */ private function getSciencemeshShareHelper() { diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index a26663d58b3..a19eb50faf7 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -10,8 +10,10 @@ declare(strict_types=1); namespace OCA\Files_Sharing\Controller; use Exception; +use OC\Files\FileInfo; use OC\Files\Storage\Wrapper\Wrapper; use OCA\Circles\Api\v1\Circles; +use OCA\Deck\Sharing\ShareAPIHelper; use OCA\Files\Helper; use OCA\Files_Sharing\Exceptions\SharingRightsException; use OCA\Files_Sharing\External\Storage; @@ -596,7 +598,7 @@ class ShareAPIController extends OCSController { // combine all permissions to determine if the user can share this file $nodes = $userFolder->getById($node->getId()); foreach ($nodes as $nodeById) { - /** @var \OC\Files\FileInfo $fileInfo */ + /** @var FileInfo $fileInfo */ $fileInfo = $node->getFileInfo(); $fileInfo['permissions'] |= $nodeById->getPermissions(); } @@ -1820,7 +1822,7 @@ class ShareAPIController extends OCSController { * If the Deck application is not enabled or the helper is not available * a ContainerExceptionInterface is thrown instead. * - * @return \OCA\Deck\Sharing\ShareAPIHelper + * @return ShareAPIHelper * @throws ContainerExceptionInterface */ private function getDeckShareHelper() { @@ -1837,7 +1839,7 @@ class ShareAPIController extends OCSController { * If the sciencemesh application is not enabled or the helper is not available * a ContainerExceptionInterface is thrown instead. * - * @return \OCA\Deck\Sharing\ShareAPIHelper + * @return ShareAPIHelper * @throws ContainerExceptionInterface */ private function getSciencemeshShareHelper() { diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index 68e0d723457..ff4781eba0f 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -41,12 +41,9 @@ class Manager { /** @var string|null */ private $uid; - /** @var \OC\Files\Mount\Manager */ - private $mountManager; - public function __construct( private IDBConnection $connection, - \OC\Files\Mount\Manager $mountManager, + private \OC\Files\Mount\Manager $mountManager, private IStorageFactory $storageLoader, private IClientService $clientService, private IManager $notificationManager, @@ -60,7 +57,6 @@ class Manager { private LoggerInterface $logger, ) { $user = $userSession->getUser(); - $this->mountManager = $mountManager; $this->uid = $user ? $user->getUID() : null; } diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php index 4b3e1affdce..bb686c1ea8c 100644 --- a/apps/files_sharing/tests/ApiTest.php +++ b/apps/files_sharing/tests/ApiTest.php @@ -1281,7 +1281,7 @@ class ApiTest extends TestCase { \OC_Hook::clear('\OCA\Files_Sharing\Tests\ApiTest', 'initTestMountPointsHook'); } - public function datesProvider() { + public static function datesProvider() { $date = new \DateTime(); $date->setTime(0, 0); $date->add(new \DateInterval('P5D')); @@ -1297,9 +1297,9 @@ class ApiTest extends TestCase { /** * Make sure only ISO 8601 dates are accepted * - * @dataProvider datesProvider * @group RoutingWeirdness */ + #[\PHPUnit\Framework\Attributes\DataProvider('datesProvider')] public function testPublicLinkExpireDate($date, $valid): void { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); diff --git a/apps/files_sharing/tests/ApplicationTest.php b/apps/files_sharing/tests/ApplicationTest.php index 3ccaedcf568..84a3f4b372b 100644 --- a/apps/files_sharing/tests/ApplicationTest.php +++ b/apps/files_sharing/tests/ApplicationTest.php @@ -87,9 +87,7 @@ class ApplicationTest extends TestCase { return $result; } - /** - * @dataProvider providesDataForCanGet - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesDataForCanGet')] public function testCheckDirectCanBeDownloaded(string $path, Folder $userFolder, bool $run): void { $user = $this->createMock(IUser::class); $user->method('getUID')->willReturn('test'); @@ -168,9 +166,7 @@ class ApplicationTest extends TestCase { return $return; } - /** - * @dataProvider providesDataForCanZip - */ + #[\PHPUnit\Framework\Attributes\DataProvider('providesDataForCanZip')] public function testCheckZipCanBeDownloaded(string $dir, array $files, Folder $userFolder, bool $run): void { $user = $this->createMock(IUser::class); $user->method('getUID')->willReturn('test'); diff --git a/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php b/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php index 09a53cf25ee..572463a9ebc 100644 --- a/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php +++ b/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php @@ -36,9 +36,9 @@ class ShareRecipientSorterTest extends TestCase { } /** - * @dataProvider sortDataProvider * @param $data */ + #[\PHPUnit\Framework\Attributes\DataProvider('sortDataProvider')] public function testSort($data): void { $node = $this->createMock(Node::class); @@ -115,7 +115,7 @@ class ShareRecipientSorterTest extends TestCase { $this->assertEquals($originalArray, $workArray); } - public function sortDataProvider() { + public static function sortDataProvider() { return [[ [ #0 – sort properly and otherwise keep existing order diff --git a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php index 33a4403b23c..6f0960bf46c 100644 --- a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php +++ b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php @@ -169,14 +169,14 @@ class CleanupRemoteStoragesTest extends TestCase { $output ->expects($this->any()) ->method('writeln') - ->willReturnCallback(function (string $text) use (&$outputCalls) { + ->willReturnCallback(function (string $text) use (&$outputCalls): void { $outputCalls[] = $text; }); $this->cloudIdManager ->expects($this->any()) ->method('getCloudId') - ->will($this->returnCallback(function (string $user, string $remote) { + ->willReturnCallback(function (string $user, string $remote) { $cloudIdMock = $this->createMock(ICloudId::class); // The remotes are already sanitized in the original data, so @@ -187,7 +187,7 @@ class CleanupRemoteStoragesTest extends TestCase { ->willReturn($remote); return $cloudIdMock; - })); + }); $this->command->execute($input, $output); diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index 43465800bf8..8bb220d684b 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -272,7 +272,7 @@ class ShareAPIControllerTest extends TestCase { $node->expects($this->once()) ->method('lock') ->with(ILockingProvider::LOCK_SHARED) - ->will($this->throwException(new LockedException('mypath'))); + ->willThrowException(new LockedException('mypath')); $this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteFromSelf', [$share])); $this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteShare', [$share])); @@ -824,9 +824,7 @@ class ShareAPIControllerTest extends TestCase { return $data; } - /** - * @dataProvider dataGetShare - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetShare')] public function testGetShare(IShare $share, array $result): void { /** @var ShareAPIController&MockObject $ocs */ $ocs = $this->getMockBuilder(ShareAPIController::class) @@ -1457,9 +1455,7 @@ class ShareAPIControllerTest extends TestCase { return $data; } - /** - * @dataProvider dataGetShares - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetShares')] public function testGetShares(array $getSharesParameters, array $shares, array $extraShareTypes, array $expected): void { /** @var ShareAPIController&MockObject $ocs */ $ocs = $this->getMockBuilder(ShareAPIController::class) @@ -1575,9 +1571,7 @@ class ShareAPIControllerTest extends TestCase { $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); } - /** - * @dataProvider dataCanAccessShareWithPermissions - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataCanAccessShareWithPermissions')] public function testCanAccessShareWithPermissions(int $permissions, bool $expected): void { $share = $this->createMock(IShare::class); $share->method('getShareType')->willReturn(IShare::TYPE_USER); @@ -1615,9 +1609,7 @@ class ShareAPIControllerTest extends TestCase { ]; } - /** - * @dataProvider dataCanAccessShareAsGroupMember - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataCanAccessShareAsGroupMember')] public function testCanAccessShareAsGroupMember(string $group, bool $expected): void { $share = $this->createMock(IShare::class); $share->method('getShareType')->willReturn(IShare::TYPE_GROUP); @@ -1695,13 +1687,13 @@ class ShareAPIControllerTest extends TestCase { } /** - * @dataProvider dataCanAccessRoomShare * * @param bool $expects * @param IShare $share * @param bool helperAvailable * @param bool canAccessShareByHelper */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataCanAccessRoomShare')] public function testCanAccessRoomShare(bool $expected, IShare $share, bool $helperAvailable, bool $canAccessShareByHelper): void { $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->method('getUserFolder') @@ -1761,7 +1753,7 @@ class ShareAPIControllerTest extends TestCase { $userFolder->expects($this->once()) ->method('get') ->with('invalid-path') - ->will($this->throwException(new NotFoundException())); + ->willThrowException(new NotFoundException()); $this->ocs->createShare('invalid-path'); } @@ -2935,9 +2927,7 @@ class ShareAPIControllerTest extends TestCase { $this->assertEquals($expected->getData(), $result->getData()); } - /** - * @dataProvider publicUploadParamsProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('publicUploadParamsProvider')] public function testUpdateLinkShareEnablePublicUpload($permissions, $publicUpload, $expireDate, $password): void { $ocs = $this->mockFormatShare(); @@ -2986,7 +2976,7 @@ class ShareAPIControllerTest extends TestCase { } - public function publicLinkValidPermissionsProvider() { + public static function publicLinkValidPermissionsProvider() { return [ [Constants::PERMISSION_CREATE], [Constants::PERMISSION_READ], @@ -2996,9 +2986,7 @@ class ShareAPIControllerTest extends TestCase { ]; } - /** - * @dataProvider publicLinkValidPermissionsProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('publicLinkValidPermissionsProvider')] public function testUpdateLinkShareSetCRUDPermissions($permissions): void { $ocs = $this->mockFormatShare(); @@ -3043,7 +3031,7 @@ class ShareAPIControllerTest extends TestCase { $this->assertEquals($expected->getData(), $result->getData()); } - public function publicLinkInvalidPermissionsProvider1() { + public static function publicLinkInvalidPermissionsProvider1() { return [ [Constants::PERMISSION_DELETE], [Constants::PERMISSION_UPDATE], @@ -3051,9 +3039,7 @@ class ShareAPIControllerTest extends TestCase { ]; } - /** - * @dataProvider publicLinkInvalidPermissionsProvider1 - */ + #[\PHPUnit\Framework\Attributes\DataProvider('publicLinkInvalidPermissionsProvider1')] public function testUpdateLinkShareSetInvalidCRUDPermissions1($permissions): void { $this->expectException(OCSBadRequestException::class); $this->expectExceptionMessage('Share must at least have READ or CREATE permissions'); @@ -3061,16 +3047,14 @@ class ShareAPIControllerTest extends TestCase { $this->testUpdateLinkShareSetCRUDPermissions($permissions, null); } - public function publicLinkInvalidPermissionsProvider2() { + public static function publicLinkInvalidPermissionsProvider2() { return [ [Constants::PERMISSION_CREATE | Constants::PERMISSION_DELETE], [Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE], ]; } - /** - * @dataProvider publicLinkInvalidPermissionsProvider2 - */ + #[\PHPUnit\Framework\Attributes\DataProvider('publicLinkInvalidPermissionsProvider2')] public function testUpdateLinkShareSetInvalidCRUDPermissions2($permissions): void { $this->expectException(OCSBadRequestException::class); $this->expectExceptionMessage('Share must have READ permission if UPDATE or DELETE permission is set'); @@ -3106,7 +3090,7 @@ class ShareAPIControllerTest extends TestCase { $ocs->updateShare(42, null, 'password', null, 'true', '2000-01-a'); } - public function publicUploadParamsProvider() { + public static function publicUploadParamsProvider() { return [ [null, 'true', null, 'password'], // legacy had no delete @@ -3122,9 +3106,7 @@ class ShareAPIControllerTest extends TestCase { ]; } - /** - * @dataProvider publicUploadParamsProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('publicUploadParamsProvider')] public function testUpdateLinkSharePublicUploadNotAllowed($permissions, $publicUpload, $expireDate, $password): void { $this->expectException(OCSForbiddenException::class); $this->expectExceptionMessage('Public upload disabled by the administrator'); @@ -4900,13 +4882,13 @@ class ShareAPIControllerTest extends TestCase { } /** - * @dataProvider dataFormatShare * * @param array $expects * @param IShare $share * @param array $users * @param $exception */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataFormatShare')] public function testFormatShare(array $expects, IShare $share, array $users, $exception): void { $this->userManager->method('get')->willReturnMap($users); @@ -5119,13 +5101,13 @@ class ShareAPIControllerTest extends TestCase { } /** - * @dataProvider dataFormatRoomShare * * @param array $expects * @param IShare $share * @param bool $helperAvailable * @param array $formatShareByHelper */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataFormatRoomShare')] public function testFormatRoomShare(array $expects, IShare $share, bool $helperAvailable, array $formatShareByHelper): void { $this->rootFolder->method('getUserFolder') ->with($this->currentUser) diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php index 9a576f86d42..011210aff42 100644 --- a/apps/files_sharing/tests/Controller/ShareControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php @@ -176,7 +176,7 @@ class ShareControllerTest extends \Test\TestCase { ->expects($this->once()) ->method('getShareByToken') ->with('invalidtoken') - ->will($this->throwException(new ShareNotFound())); + ->willThrowException(new ShareNotFound()); $this->expectException(NotFoundException::class); @@ -613,9 +613,9 @@ class ShareControllerTest extends \Test\TestCase { $this->l10n->expects($this->any()) ->method('t') - ->will($this->returnCallback(function ($text, $parameters) { + ->willReturnCallback(function ($text, $parameters) { return vsprintf($text, $parameters); - })); + }); $this->defaults->expects(self::any()) ->method('getProductName') diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php index 21e0d90ec95..18e1bf0347b 100644 --- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php @@ -70,7 +70,7 @@ class ShareesAPIControllerTest extends TestCase { ); } - public function dataSearch(): array { + public static function dataSearch(): array { $noRemote = [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_EMAIL]; $allTypes = [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_REMOTE, IShare::TYPE_REMOTE_GROUP, IShare::TYPE_EMAIL]; @@ -198,7 +198,6 @@ class ShareesAPIControllerTest extends TestCase { } /** - * @dataProvider dataSearch * * @param array $getData * @param string $apiSetting @@ -212,6 +211,7 @@ class ShareesAPIControllerTest extends TestCase { * @param bool $allowGroupSharing * @throws OCSBadRequestException */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSearch')] public function testSearch( array $getData, string $apiSetting, @@ -302,7 +302,7 @@ class ShareesAPIControllerTest extends TestCase { $this->assertInstanceOf(DataResponse::class, $sharees->search($search, $itemType, $page, $perPage, $shareType)); } - public function dataSearchInvalid(): array { + public static function dataSearchInvalid(): array { return [ // Test invalid pagination [[ @@ -329,11 +329,11 @@ class ShareesAPIControllerTest extends TestCase { } /** - * @dataProvider dataSearchInvalid * * @param array $getData * @param string $message */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSearchInvalid')] public function testSearchInvalid($getData, $message): void { $page = $getData['page'] ?? 1; $perPage = $getData['perPage'] ?? 200; @@ -377,7 +377,7 @@ class ShareesAPIControllerTest extends TestCase { } } - public function dataIsRemoteSharingAllowed() { + public static function dataIsRemoteSharingAllowed() { return [ ['file', true], ['folder', true], @@ -387,11 +387,11 @@ class ShareesAPIControllerTest extends TestCase { } /** - * @dataProvider dataIsRemoteSharingAllowed * * @param string $itemType * @param bool $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataIsRemoteSharingAllowed')] public function testIsRemoteSharingAllowed($itemType, $expected): void { $this->assertSame($expected, $this->invokePrivate($this->sharees, 'isRemoteSharingAllowed', [$itemType])); } @@ -420,7 +420,7 @@ class ShareesAPIControllerTest extends TestCase { $this->sharees->search('', null, 1, 10, [], false); } - public function dataGetPaginationLink() { + public static function dataGetPaginationLink() { return [ [1, '/ocs/v1.php', ['perPage' => 2], '<?perPage=2&page=2>; rel="next"'], [10, '/ocs/v2.php', ['perPage' => 2], '<?perPage=2&page=11>; rel="next"'], @@ -428,13 +428,13 @@ class ShareesAPIControllerTest extends TestCase { } /** - * @dataProvider dataGetPaginationLink * * @param int $page * @param string $scriptName * @param array $params * @param array $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetPaginationLink')] public function testGetPaginationLink($page, $scriptName, $params, $expected): void { $this->request->expects($this->once()) ->method('getScriptName') @@ -443,7 +443,7 @@ class ShareesAPIControllerTest extends TestCase { $this->assertEquals($expected, $this->invokePrivate($this->sharees, 'getPaginationLink', [$page, $params])); } - public function dataIsV2() { + public static function dataIsV2() { return [ ['/ocs/v1.php', false], ['/ocs/v2.php', true], @@ -451,11 +451,11 @@ class ShareesAPIControllerTest extends TestCase { } /** - * @dataProvider dataIsV2 * * @param string $scriptName * @param bool $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataIsV2')] public function testIsV2($scriptName, $expected): void { $this->request->expects($this->once()) ->method('getScriptName') diff --git a/apps/files_sharing/tests/ExpireSharesJobTest.php b/apps/files_sharing/tests/ExpireSharesJobTest.php index a9ed6d659eb..42bc5a4b659 100644 --- a/apps/files_sharing/tests/ExpireSharesJobTest.php +++ b/apps/files_sharing/tests/ExpireSharesJobTest.php @@ -90,7 +90,7 @@ class ExpireSharesJobTest extends \Test\TestCase { return $shares; } - public function dataExpireLinkShare() { + public static function dataExpireLinkShare() { return [ [false, '', false, false], [false, '', true, false], @@ -106,13 +106,13 @@ class ExpireSharesJobTest extends \Test\TestCase { } /** - * @dataProvider dataExpireLinkShare * * @param bool addExpiration Should we add an expire date * @param string $interval The dateInterval * @param bool $addInterval If true add to the current time if false subtract * @param bool $shouldExpire Should this share be expired */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataExpireLinkShare')] public function testExpireLinkShare($addExpiration, $interval, $addInterval, $shouldExpire): void { $this->loginAsUser($this->user1); diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php index d074c5470f6..fbe6eb1e85b 100644 --- a/apps/files_sharing/tests/External/ManagerTest.php +++ b/apps/files_sharing/tests/External/ManagerTest.php @@ -108,10 +108,10 @@ class ManagerTest extends TestCase { $this->userManager->expects($this->any())->method('get')->willReturn($this->user); $this->groupManager->expects($this->any())->method(('getUserGroups'))->willReturn([$group1, $group2]); $this->groupManager->expects($this->any())->method(('get')) - ->will($this->returnValueMap([ + ->willReturnMap([ ['group1', $group1], ['group2', $group2], - ])); + ]); } protected function tearDown(): void { diff --git a/apps/files_sharing/tests/ExternalStorageTest.php b/apps/files_sharing/tests/ExternalStorageTest.php index 71b740dd3ac..1d9d2eed7bd 100644 --- a/apps/files_sharing/tests/ExternalStorageTest.php +++ b/apps/files_sharing/tests/ExternalStorageTest.php @@ -20,7 +20,7 @@ use OCP\Http\Client\IResponse; * @group DB */ class ExternalStorageTest extends \Test\TestCase { - public function optionsProvider() { + public static function optionsProvider() { return [ [ 'http://remoteserver:8080/owncloud', @@ -88,9 +88,7 @@ class ExternalStorageTest extends \Test\TestCase { ); } - /** - * @dataProvider optionsProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('optionsProvider')] public function testStorageMountOptions($inputUri, $baseUri): void { $storage = $this->getTestStorage($inputUri); $this->assertEquals($baseUri, $storage->getBaseUri()); diff --git a/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php b/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php index 618aa116adb..efc6b3f7f7f 100644 --- a/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php +++ b/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php @@ -73,12 +73,12 @@ class OCSShareAPIMiddlewareTest extends \Test\TestCase { } /** - * @dataProvider dataBeforeController * * @param Controller $controller * @param bool $enabled * @param bool $exception */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataBeforeController')] public function testBeforeController(Controller $controller, $enabled, $exception): void { $this->shareManager->method('shareApiEnabled')->willReturn($enabled); @@ -105,11 +105,11 @@ class OCSShareAPIMiddlewareTest extends \Test\TestCase { } /** - * @dataProvider dataAfterController * * @param Controller $controller * @param bool $called */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataAfterController')] public function testAfterController(Controller $controller): void { if ($controller instanceof ShareAPIController) { $controller->expects($this->once())->method('cleanup'); diff --git a/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php b/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php index 2db19203f73..3d86007a54c 100644 --- a/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php +++ b/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php @@ -80,7 +80,7 @@ class SharingCheckMiddlewareTest extends \Test\TestCase { $this->assertFalse(self::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled')); } - public function externalSharesChecksDataProvider() { + public static function externalSharesChecksDataProvider() { $data = []; foreach ([false, true] as $annIn) { @@ -115,9 +115,7 @@ class SharingCheckMiddlewareTest extends \Test\TestCase { return $data; } - /** - * @dataProvider externalSharesChecksDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('externalSharesChecksDataProvider')] public function testExternalSharesChecks($annotations, $config, $expectedResult): void { $this->reflector ->expects($this->atLeastOnce()) @@ -131,9 +129,7 @@ class SharingCheckMiddlewareTest extends \Test\TestCase { $this->assertEquals($expectedResult, self::invokePrivate($this->sharingCheckMiddleware, 'externalSharesChecks')); } - /** - * @dataProvider externalSharesChecksDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('externalSharesChecksDataProvider')] public function testBeforeControllerWithExternalShareControllerWithSharingEnabled($annotations, $config, $noException): void { $this->appManager ->expects($this->once()) diff --git a/apps/files_sharing/tests/MountProviderTest.php b/apps/files_sharing/tests/MountProviderTest.php index 8f90ec1cbea..e043a1cb1ef 100644 --- a/apps/files_sharing/tests/MountProviderTest.php +++ b/apps/files_sharing/tests/MountProviderTest.php @@ -10,6 +10,7 @@ namespace OCA\Files_Sharing\Tests; use OC\Memcache\NullCache; use OC\Share20\Share; use OCA\Files_Sharing\MountProvider; +use OCA\Files_Sharing\SharedMount; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountManager; @@ -61,8 +62,8 @@ class MountProviderTest extends \Test\TestCase { $shareAttributes = $this->createMock(IShareAttributes::class); $shareAttributes->method('toArray')->willReturn($attrs); - $shareAttributes->method('getAttribute')->will( - $this->returnCallback(function ($scope, $key) use ($attrs) { + $shareAttributes->method('getAttribute')->willReturnCallback( + function ($scope, $key) use ($attrs) { $result = null; foreach ($attrs as $attr) { if ($attr['key'] === $key && $attr['scope'] === $scope) { @@ -70,7 +71,7 @@ class MountProviderTest extends \Test\TestCase { } } return $result; - }) + } ); return $shareAttributes; } @@ -82,7 +83,7 @@ class MountProviderTest extends \Test\TestCase { ->willReturn($permissions); $share->expects($this->any()) ->method('getAttributes') - ->will($this->returnValue($this->makeMockShareAttributes($attributes))); + ->willReturn($this->makeMockShareAttributes($attributes)); $share->expects($this->any()) ->method('getShareOwner') ->willReturn($owner); @@ -164,7 +165,7 @@ class MountProviderTest extends \Test\TestCase { $this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[1]); $this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[2]); $this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[3]); - /** @var OCA\Files_Sharing\SharedMount[] $mounts */ + /** @var SharedMount[] $mounts */ $mountedShare1 = $mounts[0]->getShare(); $this->assertEquals('2', $mountedShare1->getId()); $this->assertEquals('user2', $mountedShare1->getShareOwner()); @@ -332,12 +333,12 @@ class MountProviderTest extends \Test\TestCase { * Happens when sharing the same entry to a user through multiple ways, * like several groups and also direct shares at the same time. * - * @dataProvider mergeSharesDataProvider * * @param array $userShares array of user share specs * @param array $groupShares array of group share specs * @param array $expectedShares array of expected supershare specs */ + #[\PHPUnit\Framework\Attributes\DataProvider('mergeSharesDataProvider')] public function testMergeShares($userShares, $groupShares, $expectedShares, $moveFails = false): void { $rootFolder = $this->createMock(IRootFolder::class); $userManager = $this->createMock(IUserManager::class); @@ -378,7 +379,7 @@ class MountProviderTest extends \Test\TestCase { if ($moveFails) { $this->shareManager->expects($this->any()) ->method('moveShare') - ->will($this->throwException(new \InvalidArgumentException())); + ->willThrowException(new \InvalidArgumentException()); } $mounts = $this->provider->getMountsForUser($this->user, $this->loader); @@ -390,7 +391,7 @@ class MountProviderTest extends \Test\TestCase { $this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mount); // supershare - /** @var OCA\Files_Sharing\SharedMount $mount */ + /** @var SharedMount $mount */ $share = $mount->getShare(); $this->assertEquals($expectedShare[0], $share->getId()); diff --git a/apps/files_sharing/tests/ShareTest.php b/apps/files_sharing/tests/ShareTest.php index 21ffde08735..737ad6dcb4e 100644 --- a/apps/files_sharing/tests/ShareTest.php +++ b/apps/files_sharing/tests/ShareTest.php @@ -189,8 +189,8 @@ class ShareTest extends TestCase { /** * shared files should never have delete permissions - * @dataProvider dataProviderTestFileSharePermissions */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataProviderTestFileSharePermissions')] public function testFileSharePermissions($permission, $expectedvalid): void { $pass = true; try { @@ -208,7 +208,7 @@ class ShareTest extends TestCase { $this->assertEquals($expectedvalid, $pass); } - public function dataProviderTestFileSharePermissions() { + public static function dataProviderTestFileSharePermissions() { $permission1 = Constants::PERMISSION_ALL; $permission3 = Constants::PERMISSION_READ; $permission4 = Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE; diff --git a/apps/files_sharing/tests/SharedMountTest.php b/apps/files_sharing/tests/SharedMountTest.php index 3e1930ef10d..cc9c70a241f 100644 --- a/apps/files_sharing/tests/SharedMountTest.php +++ b/apps/files_sharing/tests/SharedMountTest.php @@ -225,11 +225,11 @@ class SharedMountTest extends TestCase { } /** - * @dataProvider dataProviderTestStripUserFilesPath * @param string $path * @param string $expectedResult * @param bool $exception if a exception is expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataProviderTestStripUserFilesPath')] public function testStripUserFilesPath($path, $expectedResult, $exception): void { $testClass = new DummyTestClassSharedMount(null, null); try { @@ -244,7 +244,7 @@ class SharedMountTest extends TestCase { } } - public function dataProviderTestStripUserFilesPath() { + public static function dataProviderTestStripUserFilesPath() { return [ ['/user/files/foo.txt', '/foo.txt', false], ['/user/files/folder/foo.txt', '/folder/foo.txt', false], diff --git a/apps/files_sharing/tests/SharedStorageTest.php b/apps/files_sharing/tests/SharedStorageTest.php index 1cd9bf0af8f..1c1f0a7b71d 100644 --- a/apps/files_sharing/tests/SharedStorageTest.php +++ b/apps/files_sharing/tests/SharedStorageTest.php @@ -571,7 +571,7 @@ class SharedStorageTest extends TestCase { $share->method('getShareOwner')->willReturn(self::TEST_FILES_SHARING_API_USER1); $share->method('getNodeId')->willReturn(1); $ownerView = $this->createMock(View::class); - $ownerView->method('getPath')->will($this->throwException(new NotFoundException())); + $ownerView->method('getPath')->willThrowException(new NotFoundException()); $storage = new SharedStorage([ 'ownerView' => $ownerView, 'superShare' => $share, diff --git a/apps/files_sharing/tests/SharesReminderJobTest.php b/apps/files_sharing/tests/SharesReminderJobTest.php index 7a480fccb23..ce468e279ec 100644 --- a/apps/files_sharing/tests/SharesReminderJobTest.php +++ b/apps/files_sharing/tests/SharesReminderJobTest.php @@ -95,7 +95,7 @@ class SharesReminderJobTest extends \Test\TestCase { parent::tearDown(); } - public function dataSharesReminder() { + public static function dataSharesReminder() { $someMail = 'test@test.com'; $noExpirationDate = null; $today = new \DateTime(); @@ -144,7 +144,6 @@ class SharesReminderJobTest extends \Test\TestCase { } /** - * @dataProvider dataSharesReminder * * @param \DateTime|null $expirationDate Share expiration date * @param string $email Share with this email. If empty, the share is of type TYPE_USER and the sharee is user2 @@ -152,6 +151,7 @@ class SharesReminderJobTest extends \Test\TestCase { * @param int $permissions * @param bool $shouldBeReminded */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSharesReminder')] public function testSharesReminder( ?\DateTime $expirationDate, string $email, bool $isEmpty, int $permissions, bool $shouldBeReminded, ): void { diff --git a/apps/files_sharing/tests/UpdaterTest.php b/apps/files_sharing/tests/UpdaterTest.php index bed6aea099f..23044e0b2f3 100644 --- a/apps/files_sharing/tests/UpdaterTest.php +++ b/apps/files_sharing/tests/UpdaterTest.php @@ -124,7 +124,7 @@ class UpdaterTest extends TestCase { Filesystem::getLoader()->removeStorageWrapper('oc_trashbin'); } - public function shareFolderProvider() { + public static function shareFolderProvider() { return [ ['/'], ['/my_shares'], @@ -134,10 +134,10 @@ class UpdaterTest extends TestCase { /** * if a file gets shared the etag for the recipients root should change * - * @dataProvider shareFolderProvider * * @param string $shareFolder share folder to use */ + #[\PHPUnit\Framework\Attributes\DataProvider('shareFolderProvider')] public function testShareFile($shareFolder): void { $config = Server::get(IConfig::class); $oldShareFolder = $config->getSystemValue('share_folder'); diff --git a/apps/files_trashbin/tests/Command/CleanUpTest.php b/apps/files_trashbin/tests/Command/CleanUpTest.php index 3dce8f0c92e..41ed0e1e960 100644 --- a/apps/files_trashbin/tests/Command/CleanUpTest.php +++ b/apps/files_trashbin/tests/Command/CleanUpTest.php @@ -69,9 +69,7 @@ class CleanUpTest extends TestCase { $this->assertCount(10, $result); } - /** - * @dataProvider dataTestRemoveDeletedFiles - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestRemoveDeletedFiles')] public function testRemoveDeletedFiles(bool $nodeExists): void { $this->initTable(); $this->rootFolder @@ -129,7 +127,7 @@ class CleanUpTest extends TestCase { */ public function testExecuteDeleteListOfUsers(): void { $userIds = ['user1', 'user2', 'user3']; - $instance = $this->getMockBuilder(\OCA\Files_Trashbin\Command\CleanUp::class) + $instance = $this->getMockBuilder(CleanUp::class) ->onlyMethods(['removeDeletedFiles']) ->setConstructorArgs([$this->rootFolder, $this->userManager, $this->dbConnection]) ->getMock(); @@ -159,7 +157,7 @@ class CleanUpTest extends TestCase { public function testExecuteAllUsers(): void { $userIds = []; $backendUsers = ['user1', 'user2']; - $instance = $this->getMockBuilder(\OCA\Files_Trashbin\Command\CleanUp::class) + $instance = $this->getMockBuilder(CleanUp::class) ->onlyMethods(['removeDeletedFiles']) ->setConstructorArgs([$this->rootFolder, $this->userManager, $this->dbConnection]) ->getMock(); diff --git a/apps/files_trashbin/tests/ExpirationTest.php b/apps/files_trashbin/tests/ExpirationTest.php index aab07de8162..3348edc4016 100644 --- a/apps/files_trashbin/tests/ExpirationTest.php +++ b/apps/files_trashbin/tests/ExpirationTest.php @@ -82,9 +82,7 @@ class ExpirationTest extends \Test\TestCase { ]; } - /** - * @dataProvider expirationData - */ + #[\PHPUnit\Framework\Attributes\DataProvider('expirationData')] public function testExpiration(string $retentionObligation, int $timeNow, int $timestamp, bool $quotaExceeded, bool $expectedResult): void { $mockedConfig = $this->getMockedConfig($retentionObligation); $mockedTimeFactory = $this->getMockedTimeFactory($timeNow); @@ -110,9 +108,7 @@ class ExpirationTest extends \Test\TestCase { } - /** - * @dataProvider timestampTestData - */ + #[\PHPUnit\Framework\Attributes\DataProvider('timestampTestData')] public function testGetMaxAgeAsTimestamp(string $configValue, bool|int $expectedMaxAgeTimestamp): void { $mockedConfig = $this->getMockedConfig($configValue); $mockedTimeFactory = $this->getMockedTimeFactory( diff --git a/apps/files_trashbin/tests/Sabre/TrashbinPluginTest.php b/apps/files_trashbin/tests/Sabre/TrashbinPluginTest.php index 6c566afc738..87aca2753ef 100644 --- a/apps/files_trashbin/tests/Sabre/TrashbinPluginTest.php +++ b/apps/files_trashbin/tests/Sabre/TrashbinPluginTest.php @@ -29,9 +29,7 @@ class TrashbinPluginTest extends TestCase { $this->server = new Server($tree); } - /** - * @dataProvider quotaProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('quotaProvider')] public function testQuota(int $quota, int $fileSize, bool $expectedResult): void { $fileInfo = $this->createMock(ITrashItem::class); $fileInfo->method('getSize') diff --git a/apps/files_trashbin/tests/StorageTest.php b/apps/files_trashbin/tests/StorageTest.php index 2b2508a358b..c58ddec97dd 100644 --- a/apps/files_trashbin/tests/StorageTest.php +++ b/apps/files_trashbin/tests/StorageTest.php @@ -311,7 +311,7 @@ class StorageTest extends \Test\TestCase { $recipientUser = $this->getUniqueId('recipient_'); Server::get(IUserManager::class)->createUser($recipientUser, $recipientUser); - $node = \OCP\Server::get(IRootFolder::class)->getUserFolder($this->user)->get('share'); + $node = Server::get(IRootFolder::class)->getUserFolder($this->user)->get('share'); $share = Server::get(\OCP\Share\IManager::class)->newShare(); $share->setNode($node) ->setShareType(IShare::TYPE_USER) @@ -362,7 +362,7 @@ class StorageTest extends \Test\TestCase { $recipientUser = $this->getUniqueId('recipient_'); Server::get(IUserManager::class)->createUser($recipientUser, $recipientUser); - $node = \OCP\Server::get(IRootFolder::class)->getUserFolder($this->user)->get('share'); + $node = Server::get(IRootFolder::class)->getUserFolder($this->user)->get('share'); $share = Server::get(\OCP\Share\IManager::class)->newShare(); $share->setNode($node) ->setShareType(IShare::TYPE_USER) @@ -496,7 +496,7 @@ class StorageTest extends \Test\TestCase { /** * @var Temporary&MockObject $storage */ - $storage = $this->getMockBuilder(\OC\Files\Storage\Temporary::class) + $storage = $this->getMockBuilder(Temporary::class) ->setConstructorArgs([[]]) ->onlyMethods(['rename', 'unlink', 'moveFromStorage']) ->getMock(); @@ -533,7 +533,7 @@ class StorageTest extends \Test\TestCase { /** * @var Temporary&MockObject $storage */ - $storage = $this->getMockBuilder(\OC\Files\Storage\Temporary::class) + $storage = $this->getMockBuilder(Temporary::class) ->setConstructorArgs([[]]) ->onlyMethods(['rename', 'unlink', 'rmdir']) ->getMock(); @@ -560,14 +560,12 @@ class StorageTest extends \Test\TestCase { $this->assertCount(0, $results); } - /** - * @dataProvider dataTestShouldMoveToTrash - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestShouldMoveToTrash')] public function testShouldMoveToTrash(string $mountPoint, string $path, bool $userExists, bool $appDisablesTrash, bool $expected): void { $fileID = 1; $cache = $this->createMock(ICache::class); $cache->expects($this->any())->method('getId')->willReturn($fileID); - $tmpStorage = $this->createMock(\OC\Files\Storage\Temporary::class); + $tmpStorage = $this->createMock(Temporary::class); $tmpStorage->expects($this->any())->method('getCache')->willReturn($cache); $userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor()->getMock(); diff --git a/apps/files_trashbin/tests/TrashbinTest.php b/apps/files_trashbin/tests/TrashbinTest.php index d8486ccbdc2..6104a242104 100644 --- a/apps/files_trashbin/tests/TrashbinTest.php +++ b/apps/files_trashbin/tests/TrashbinTest.php @@ -354,7 +354,7 @@ class TrashbinTest extends \Test\TestCase { * Test restoring a file */ public function testRestoreFileInRoot(): void { - $userFolder = \OCP\Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1); + $userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1); $file = $userFolder->newFile('file1.txt'); $file->putContent('foo'); @@ -386,7 +386,7 @@ class TrashbinTest extends \Test\TestCase { * Test restoring a file in subfolder */ public function testRestoreFileInSubfolder(): void { - $userFolder = \OCP\Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1); + $userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1); $folder = $userFolder->newFolder('folder'); $file = $folder->newFile('file1.txt'); $file->putContent('foo'); @@ -419,7 +419,7 @@ class TrashbinTest extends \Test\TestCase { * Test restoring a folder */ public function testRestoreFolder(): void { - $userFolder = \OCP\Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1); + $userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1); $folder = $userFolder->newFolder('folder'); $file = $folder->newFile('file1.txt'); $file->putContent('foo'); @@ -452,7 +452,7 @@ class TrashbinTest extends \Test\TestCase { * Test restoring a file from inside a trashed folder */ public function testRestoreFileFromTrashedSubfolder(): void { - $userFolder = \OCP\Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1); + $userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1); $folder = $userFolder->newFolder('folder'); $file = $folder->newFile('file1.txt'); $file->putContent('foo'); @@ -486,7 +486,7 @@ class TrashbinTest extends \Test\TestCase { * The file should then land in the root. */ public function testRestoreFileWithMissingSourceFolder(): void { - $userFolder = \OCP\Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1); + $userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1); $folder = $userFolder->newFolder('folder'); $file = $folder->newFile('file1.txt'); $file->putContent('foo'); @@ -523,7 +523,7 @@ class TrashbinTest extends \Test\TestCase { * with the same name in the root folder */ public function testRestoreFileDoesNotOverwriteExistingInRoot(): void { - $userFolder = \OCP\Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1); + $userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1); $file = $userFolder->newFile('file1.txt'); $file->putContent('foo'); @@ -563,7 +563,7 @@ class TrashbinTest extends \Test\TestCase { * with the same name in the source folder */ public function testRestoreFileDoesNotOverwriteExistingInSubfolder(): void { - $userFolder = \OCP\Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1); + $userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1); $folder = $userFolder->newFolder('folder'); $file = $folder->newFile('file1.txt'); $file->putContent('foo'); @@ -617,7 +617,7 @@ class TrashbinTest extends \Test\TestCase { * the file to root instead */ public function testRestoreFileIntoReadOnlySourceFolder(): void { - $userFolder = \OCP\Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1); + $userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1); $folder = $userFolder->newFolder('folder'); $file = $folder->newFile('file1.txt'); $file->putContent('foo'); @@ -673,7 +673,7 @@ class TrashbinTest extends \Test\TestCase { Filesystem::tearDown(); \OC_User::setUserId($user); \OC_Util::setupFS($user); - \OCP\Server::get(IRootFolder::class)->getUserFolder($user); + Server::get(IRootFolder::class)->getUserFolder($user); } } diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php index 8572b78b2c9..6d53a19a518 100644 --- a/apps/files_versions/lib/Storage.php +++ b/apps/files_versions/lib/Storage.php @@ -9,6 +9,7 @@ namespace OCA\Files_Versions; use OC\Files\Filesystem; +use OC\Files\ObjectStore\ObjectStoreStorage; use OC\Files\Search\SearchBinaryOperator; use OC\Files\Search\SearchComparison; use OC\Files\Search\SearchQuery; @@ -419,8 +420,8 @@ class Storage { try { // TODO add a proper way of overwriting a file while maintaining file ids - if ($storage1->instanceOfStorage(\OC\Files\ObjectStore\ObjectStoreStorage::class) - || $storage2->instanceOfStorage(\OC\Files\ObjectStore\ObjectStoreStorage::class) + if ($storage1->instanceOfStorage(ObjectStoreStorage::class) + || $storage2->instanceOfStorage(ObjectStoreStorage::class) ) { $source = $storage1->fopen($internalPath1, 'r'); $result = $source !== false; diff --git a/apps/files_versions/tests/Command/CleanupTest.php b/apps/files_versions/tests/Command/CleanupTest.php index b0a5c0ca268..dd6665f5aef 100644 --- a/apps/files_versions/tests/Command/CleanupTest.php +++ b/apps/files_versions/tests/Command/CleanupTest.php @@ -43,9 +43,9 @@ class CleanupTest extends TestCase { } /** - * @dataProvider dataTestDeleteVersions * @param boolean $nodeExists */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestDeleteVersions')] public function testDeleteVersions(bool $nodeExists): void { $this->rootFolder->expects($this->once()) ->method('nodeExists') diff --git a/apps/files_versions/tests/ExpirationTest.php b/apps/files_versions/tests/ExpirationTest.php index 866e4861741..8cf412c3fe0 100644 --- a/apps/files_versions/tests/ExpirationTest.php +++ b/apps/files_versions/tests/ExpirationTest.php @@ -81,9 +81,7 @@ class ExpirationTest extends \Test\TestCase { ]; } - /** - * @dataProvider expirationData - */ + #[\PHPUnit\Framework\Attributes\DataProvider('expirationData')] public function testExpiration(string $retentionObligation, int $timeNow, int $timestamp, bool $quotaExceeded, bool $expectedResult): void { $mockedConfig = $this->getMockedConfig($retentionObligation); $mockedTimeFactory = $this->getMockedTimeFactory($timeNow); diff --git a/apps/files_versions/tests/VersioningTest.php b/apps/files_versions/tests/VersioningTest.php index 659b2cff10c..c9f7d27d7ab 100644 --- a/apps/files_versions/tests/VersioningTest.php +++ b/apps/files_versions/tests/VersioningTest.php @@ -140,8 +140,8 @@ class VersioningTest extends \Test\TestCase { /** * @medium * test expire logic - * @dataProvider versionsProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('versionsProvider')] public function testGetExpireList($versions, $sizeOfAllDeletedFiles): void { // last interval end at 2592000 diff --git a/apps/oauth2/tests/Controller/OauthApiControllerTest.php b/apps/oauth2/tests/Controller/OauthApiControllerTest.php index 0ecdb2e6b59..53dd8549196 100644 --- a/apps/oauth2/tests/Controller/OauthApiControllerTest.php +++ b/apps/oauth2/tests/Controller/OauthApiControllerTest.php @@ -223,7 +223,7 @@ class OauthApiControllerTest extends TestCase { $this->assertEquals($expected, $this->oauthApiController->getToken('refresh_token', null, 'validrefresh', null, null)); } - public function invalidClientProvider() { + public static function invalidClientProvider() { return [ ['invalidClientId', 'invalidClientSecret'], ['clientId', 'invalidClientSecret'], @@ -232,11 +232,11 @@ class OauthApiControllerTest extends TestCase { } /** - * @dataProvider invalidClientProvider * * @param string $clientId * @param string $clientSecret */ + #[\PHPUnit\Framework\Attributes\DataProvider('invalidClientProvider')] public function testRefreshTokenInvalidClient($clientId, $clientSecret): void { $expected = new JSONResponse([ 'error' => 'invalid_client', diff --git a/apps/provisioning_api/tests/CapabilitiesTest.php b/apps/provisioning_api/tests/CapabilitiesTest.php index 67a0335829c..86d2bb8c4fa 100644 --- a/apps/provisioning_api/tests/CapabilitiesTest.php +++ b/apps/provisioning_api/tests/CapabilitiesTest.php @@ -48,16 +48,14 @@ class CapabilitiesTest extends TestCase { ]; } - /** - * @dataProvider getCapabilitiesProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('getCapabilitiesProvider')] public function testGetCapabilities(bool $federationAppEnabled, bool $federatedFileSharingAppEnabled, bool $lookupServerEnabled, bool $expectedFederatedScopeEnabled, bool $expectedPublishedScopeEnabled): void { $this->appManager->expects($this->any()) ->method('isEnabledForUser') - ->will($this->returnValueMap([ + ->willReturnMap([ ['federation', null, $federationAppEnabled], ['federatedfilesharing', null, $federatedFileSharingAppEnabled], - ])); + ]); $federatedShareProvider = $this->createMock(FederatedShareProvider::class); $this->overwriteService(FederatedShareProvider::class, $federatedShareProvider); diff --git a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php index 3d2c1645d25..1b09838cbc3 100644 --- a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php +++ b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php @@ -103,9 +103,7 @@ class AppConfigControllerTest extends TestCase { ]; } - /** - * @dataProvider dataGetKeys - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetKeys')] public function testGetKeys(string $app, ?array $keys, ?\Throwable $throws, int $status): void { $api = $this->getInstance(['verifyAppId']); if ($throws instanceof \Exception) { @@ -144,9 +142,7 @@ class AppConfigControllerTest extends TestCase { ]; } - /** - * @dataProvider dataGetValue - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetValue')] public function testGetValue(string $app, string $key, string $default, ?string $return, ?\Throwable $throws, int $status): void { $api = $this->getInstance(['verifyAppId']); if ($throws instanceof \Exception) { @@ -190,9 +186,7 @@ class AppConfigControllerTest extends TestCase { ]; } - /** - * @dataProvider dataSetValue - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSetValue')] public function testSetValue(string $app, string $key, string $value, ?\Throwable $appThrows, ?\Throwable $keyThrows, int $status, int|\Throwable $type = IAppConfig::VALUE_MIXED): void { $adminUser = $this->createMock(IUser::class); $adminUser->expects($this->once()) @@ -290,9 +284,7 @@ class AppConfigControllerTest extends TestCase { ]; } - /** - * @dataProvider dataDeleteValue - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataDeleteValue')] public function testDeleteValue(string $app, string $key, ?\Throwable $appThrows, ?\Throwable $keyThrows, int $status): void { $api = $this->getInstance(['verifyAppId', 'verifyConfigKey']); if ($appThrows instanceof \Exception) { @@ -356,9 +348,7 @@ class AppConfigControllerTest extends TestCase { ]; } - /** - * @dataProvider dataVerifyAppIdThrows - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataVerifyAppIdThrows')] public function testVerifyAppIdThrows(string $app): void { $this->expectException(\InvalidArgumentException::class); @@ -375,9 +365,7 @@ class AppConfigControllerTest extends TestCase { ]; } - /** - * @dataProvider dataVerifyConfigKey - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataVerifyConfigKey')] public function testVerifyConfigKey(string $app, string $key, string $value): void { $api = $this->getInstance(); $this->invokePrivate($api, 'verifyConfigKey', [$app, $key, $value]); @@ -398,9 +386,7 @@ class AppConfigControllerTest extends TestCase { ]; } - /** - * @dataProvider dataVerifyConfigKeyThrows - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataVerifyConfigKeyThrows')] public function testVerifyConfigKeyThrows(string $app, string $key, string $value): void { $this->expectException(\InvalidArgumentException::class); diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php index e4f8b3af183..85e5d733b1f 100644 --- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php @@ -77,7 +77,7 @@ class GroupsControllerTest extends \Test\TestCase { } private function createGroup(string $gid): IGroup&MockObject { - $group = $this->createMock(\OCP\IGroup::class); + $group = $this->createMock(IGroup::class); $group ->method('getGID') ->willReturn($gid); @@ -161,9 +161,7 @@ class GroupsControllerTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataGetGroups - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetGroups')] public function testGetGroups(?string $search, int $limit, int $offset): void { $groups = [$this->createGroup('group1'), $this->createGroup('group2')]; @@ -180,12 +178,12 @@ class GroupsControllerTest extends \Test\TestCase { } /** - * @dataProvider dataGetGroups * * @param string|null $search * @param int|null $limit * @param int|null $offset */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetGroups')] public function testGetGroupsDetails($search, $limit, $offset): void { $groups = [$this->createGroup('group1'), $this->createGroup('group2')]; diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index 3f8c1566b5d..cf35a4fb324 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -199,8 +199,7 @@ class UsersControllerTest extends TestCase { ->willReturn($subAdminManager); $this->groupManager ->expects($this->any()) - ->method('displayNamesInGroup') - ->will($this->onConsecutiveCalls(['AnotherUserInTheFirstGroup' => []], ['UserInTheSecondGroup' => []])); + ->method('displayNamesInGroup')->willReturnOnConsecutiveCalls(['AnotherUserInTheFirstGroup' => []], ['UserInTheSecondGroup' => []]); $expected = [ 'users' => [ @@ -790,7 +789,7 @@ class UsersControllerTest extends TestCase { $this->logger ->expects($this->exactly(2)) ->method('info') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); @@ -814,7 +813,7 @@ class UsersControllerTest extends TestCase { ->expects($this->once()) ->method('createUser') ->with('NewUser', 'PasswordOfTheNewUser') - ->will($this->throwException($exception)); + ->willThrowException($exception); $this->logger ->expects($this->once()) ->method('error') @@ -994,7 +993,7 @@ class UsersControllerTest extends TestCase { $this->logger ->expects($this->exactly(3)) ->method('info') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); @@ -1534,9 +1533,7 @@ class UsersControllerTest extends TestCase { ]; } - /** - * @dataProvider dataSearchByPhoneNumbers - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSearchByPhoneNumbers')] public function testSearchByPhoneNumbers(string $location, array $search, int $status, ?array $searchUsers, ?array $userMatches, array $expected): void { $knownTo = 'knownTo'; $user = $this->createMock(IUser::class); @@ -1862,9 +1859,7 @@ class UsersControllerTest extends TestCase { ]; } - /** - * @dataProvider selfEditChangePropertyProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('selfEditChangePropertyProvider')] public function testEditUserRegularUserSelfEditChangeProperty($propertyName, $oldValue, $newValue): void { $loggedInUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() @@ -1940,9 +1935,7 @@ class UsersControllerTest extends TestCase { ]; } - /** - * @dataProvider selfEditChangePropertyProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('selfEditChangePropertyProvider')] public function testEditUserRegularUserSelfEditChangePropertyScope($propertyName, $oldScope, $newScope): void { $loggedInUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() @@ -2277,9 +2270,7 @@ class UsersControllerTest extends TestCase { ]; } - /** - * @dataProvider dataEditUserSelfEditChangeLanguageButForced - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataEditUserSelfEditChangeLanguageButForced')] public function testEditUserSelfEditChangeLanguageButForced($forced): void { $this->expectException(OCSException::class); @@ -2373,9 +2364,7 @@ class UsersControllerTest extends TestCase { $this->assertEquals([], $this->api->editUser('UserToEdit', 'language', 'de')->getData()); } - /** - * @dataProvider dataEditUserSelfEditChangeLanguageButForced - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataEditUserSelfEditChangeLanguageButForced')] public function testEditUserAdminEditChangeLanguageInvalidLanguage(): void { $this->expectException(OCSException::class); @@ -4363,9 +4352,7 @@ class UsersControllerTest extends TestCase { ]; } - /** - * @dataProvider dataGetEditableFields - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetEditableFields')] public function testGetEditableFields(bool $allowedToChangeDisplayName, bool $allowedToChangeEmail, string $userBackend, array $expected): void { $this->config->method('getSystemValue')->willReturnCallback(fn (string $key, mixed $default) => match ($key) { 'allow_user_to_change_display_name' => $allowedToChangeDisplayName, @@ -4400,7 +4387,7 @@ class UsersControllerTest extends TestCase { $account = $this->createMock(IAccount::class); $account->method('getProperty') - ->will($this->returnValueMap($mockedProperties)); + ->willReturnMap($mockedProperties); $this->accountManager->expects($this->any())->method('getAccount') ->with($targetUser) diff --git a/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php b/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php index 233504dbd47..c027e518a3d 100644 --- a/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php +++ b/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php @@ -44,9 +44,7 @@ class ProvisioningApiMiddlewareTest extends TestCase { ]; } - /** - * @dataProvider dataAnnotation - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataAnnotation')] public function testBeforeController(bool $subadminRequired, bool $isAdmin, bool $isSubAdmin, bool $hasSettingAuthorizationAnnotation, bool $shouldThrowException): void { $middleware = new ProvisioningApiMiddleware( $this->reflector, @@ -83,9 +81,7 @@ class ProvisioningApiMiddlewareTest extends TestCase { ]; } - /** - * @dataProvider dataAfterException - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataAfterException')] public function testAfterException(\Exception $exception, bool $forwared): void { $middleware = new ProvisioningApiMiddleware( $this->reflector, diff --git a/apps/settings/tests/Activity/SecurityProviderTest.php b/apps/settings/tests/Activity/SecurityProviderTest.php index aa1c6592883..ed9de362a87 100644 --- a/apps/settings/tests/Activity/SecurityProviderTest.php +++ b/apps/settings/tests/Activity/SecurityProviderTest.php @@ -50,9 +50,7 @@ class SecurityProviderTest extends TestCase { ]; } - /** - * @dataProvider subjectData - */ + #[\PHPUnit\Framework\Attributes\DataProvider('subjectData')] public function testParse(string $subject): void { $lang = 'ru'; $event = $this->createMock(IEvent::class); diff --git a/apps/settings/tests/AppInfo/ApplicationTest.php b/apps/settings/tests/AppInfo/ApplicationTest.php index 85be8c56178..b09412d8387 100644 --- a/apps/settings/tests/AppInfo/ApplicationTest.php +++ b/apps/settings/tests/AppInfo/ApplicationTest.php @@ -56,9 +56,7 @@ class ApplicationTest extends TestCase { ]; } - /** - * @dataProvider dataContainerQuery - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataContainerQuery')] public function testContainerQuery(string $service, string $expected): void { $this->assertTrue($this->container->query($service) instanceof $expected); } diff --git a/apps/settings/tests/Controller/AuthSettingsControllerTest.php b/apps/settings/tests/Controller/AuthSettingsControllerTest.php index 37321d02915..d195dbf83d3 100644 --- a/apps/settings/tests/Controller/AuthSettingsControllerTest.php +++ b/apps/settings/tests/Controller/AuthSettingsControllerTest.php @@ -120,7 +120,7 @@ class AuthSettingsControllerTest extends TestCase { $this->session->expects($this->once()) ->method('getId') - ->will($this->throwException(new SessionNotAvailableException())); + ->willThrowException(new SessionNotAvailableException()); $expected = new JSONResponse(); $expected->setStatus(Http::STATUS_SERVICE_UNAVAILABLE); @@ -137,7 +137,7 @@ class AuthSettingsControllerTest extends TestCase { $this->tokenProvider->expects($this->once()) ->method('getToken') ->with('sessionid') - ->will($this->throwException(new InvalidTokenException())); + ->willThrowException(new InvalidTokenException()); $expected = new JSONResponse(); $expected->setStatus(Http::STATUS_SERVICE_UNAVAILABLE); @@ -213,9 +213,7 @@ class AuthSettingsControllerTest extends TestCase { ]; } - /** - * @dataProvider dataRenameToken - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataRenameToken')] public function testUpdateRename(string $name, string $newName): void { $tokenId = 42; $token = $this->createMock(PublicKeyToken::class); @@ -253,9 +251,7 @@ class AuthSettingsControllerTest extends TestCase { ]; } - /** - * @dataProvider dataUpdateFilesystemScope - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataUpdateFilesystemScope')] public function testUpdateFilesystemScope(bool $filesystem, bool $newFilesystem): void { $tokenId = 42; $token = $this->createMock(PublicKeyToken::class); diff --git a/apps/settings/tests/Controller/MailSettingsControllerTest.php b/apps/settings/tests/Controller/MailSettingsControllerTest.php index dcb1e3efef4..1bc05ca4718 100644 --- a/apps/settings/tests/Controller/MailSettingsControllerTest.php +++ b/apps/settings/tests/Controller/MailSettingsControllerTest.php @@ -79,7 +79,7 @@ class MailSettingsControllerTest extends \Test\TestCase { ]; $this->config->expects($this->exactly(2)) ->method('setSystemValues') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); diff --git a/apps/settings/tests/Controller/UsersControllerTest.php b/apps/settings/tests/Controller/UsersControllerTest.php index d5fe38ad458..0468ce6814c 100644 --- a/apps/settings/tests/Controller/UsersControllerTest.php +++ b/apps/settings/tests/Controller/UsersControllerTest.php @@ -235,9 +235,7 @@ class UsersControllerTest extends \Test\TestCase { return $account; } - /** - * @dataProvider dataTestSetUserSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSetUserSettings')] public function testSetUserSettings(string $email, bool $validEmail, int $expectedStatus): void { $controller = $this->getController(false, ['saveUserSettings']); $user = $this->createMock(IUser::class); @@ -497,9 +495,7 @@ class UsersControllerTest extends \Test\TestCase { ); } - /** - * @dataProvider dataTestSetUserSettingsSubset - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSetUserSettingsSubset')] public function testSetUserSettingsSubset(string $property, string $propertyValue): void { $controller = $this->getController(false, ['saveUserSettings']); $user = $this->createMock(IUser::class); @@ -641,9 +637,7 @@ class UsersControllerTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataTestSaveUserSettings - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSaveUserSettings')] public function testSaveUserSettings(array $data, ?string $oldEmailAddress, ?string $oldDisplayName): void { $controller = $this->getController(); $user = $this->createMock(IUser::class); @@ -758,9 +752,7 @@ class UsersControllerTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataTestSaveUserSettingsException - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSaveUserSettingsException')] public function testSaveUserSettingsException( array $data, string $oldEmailAddress, @@ -843,9 +835,7 @@ class UsersControllerTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataTestGetVerificationCode - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetVerificationCode')] public function testGetVerificationCode(string $account, string $type, array $dataBefore, array $expectedData, bool $onlyVerificationCode): void { $message = 'Use my Federated Cloud ID to share with me: user@nextcloud.com'; $signature = 'theSignature'; @@ -940,9 +930,7 @@ class UsersControllerTest extends \Test\TestCase { $this->assertSame(Http::STATUS_BAD_REQUEST, $result->getStatus()); } - /** - * @dataProvider dataTestCanAdminChangeUserPasswords - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestCanAdminChangeUserPasswords')] public function testCanAdminChangeUserPasswords( bool $encryptionEnabled, bool $encryptionModuleLoaded, diff --git a/apps/settings/tests/Settings/Admin/MailTest.php b/apps/settings/tests/Settings/Admin/MailTest.php index 97f59b9ea64..992c7d43dba 100644 --- a/apps/settings/tests/Settings/Admin/MailTest.php +++ b/apps/settings/tests/Settings/Admin/MailTest.php @@ -38,7 +38,7 @@ class MailTest extends TestCase { ]; } - /** @dataProvider dataGetForm */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetForm')] public function testGetForm(bool $sendmail) { $finder = $this->createMock(IBinaryFinder::class); $finder->expects(self::once()) diff --git a/apps/settings/tests/Settings/Admin/SecurityTest.php b/apps/settings/tests/Settings/Admin/SecurityTest.php index fbb84854228..89a6d8c0d88 100644 --- a/apps/settings/tests/Settings/Admin/SecurityTest.php +++ b/apps/settings/tests/Settings/Admin/SecurityTest.php @@ -46,9 +46,7 @@ class SecurityTest extends TestCase { ]; } - /** - * @dataProvider encryptionSettingsProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('encryptionSettingsProvider')] public function testGetFormWithOnlyOneBackend(bool $enabled): void { $this->manager ->expects($this->once()) @@ -76,9 +74,9 @@ class SecurityTest extends TestCase { } /** - * @dataProvider encryptionSettingsProvider * @param bool $enabled */ + #[\PHPUnit\Framework\Attributes\DataProvider('encryptionSettingsProvider')] public function testGetFormWithMultipleBackends($enabled): void { $this->manager ->expects($this->once()) diff --git a/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php b/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php index f6f82ab311a..0a0ff4d84af 100644 --- a/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php +++ b/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php @@ -97,7 +97,7 @@ class AuthtokensTest extends TestCase { ]; $this->initialState->expects($this->exactly(2)) ->method('provideInitialState') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); diff --git a/apps/settings/tests/SetupChecks/DataDirectoryProtectedTest.php b/apps/settings/tests/SetupChecks/DataDirectoryProtectedTest.php index a48c6296aff..c20c78c6e16 100644 --- a/apps/settings/tests/SetupChecks/DataDirectoryProtectedTest.php +++ b/apps/settings/tests/SetupChecks/DataDirectoryProtectedTest.php @@ -54,9 +54,7 @@ class DataDirectoryProtectedTest extends TestCase { ->getMock(); } - /** - * @dataProvider dataTestStatusCode - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestStatusCode')] public function testStatusCode(array $status, string $expected, bool $hasBody): void { $responses = array_map(function ($state) use ($hasBody) { $response = $this->createMock(IResponse::class); diff --git a/apps/settings/tests/SetupChecks/ForwardedForHeadersTest.php b/apps/settings/tests/SetupChecks/ForwardedForHeadersTest.php index b57eb852d80..9b4878b45cc 100644 --- a/apps/settings/tests/SetupChecks/ForwardedForHeadersTest.php +++ b/apps/settings/tests/SetupChecks/ForwardedForHeadersTest.php @@ -43,9 +43,7 @@ class ForwardedForHeadersTest extends TestCase { ); } - /** - * @dataProvider dataForwardedForHeadersWorking - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataForwardedForHeadersWorking')] public function testForwardedForHeadersWorking(array $trustedProxies, string $remoteAddrNotForwarded, string $remoteAddr, string $result): void { $this->config->expects($this->once()) ->method('getSystemValue') diff --git a/apps/settings/tests/SetupChecks/LoggingLevelTest.php b/apps/settings/tests/SetupChecks/LoggingLevelTest.php index 9d588a4e486..67224e11e3a 100644 --- a/apps/settings/tests/SetupChecks/LoggingLevelTest.php +++ b/apps/settings/tests/SetupChecks/LoggingLevelTest.php @@ -59,7 +59,7 @@ class LoggingLevelTest extends TestCase { ]; } - /** @dataProvider dataRun */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataRun')] public function testRun(string|int $value, string $expected): void { $this->urlGenerator->method('linkToDocs')->willReturn('admin-logging'); diff --git a/apps/settings/tests/SetupChecks/SecurityHeadersTest.php b/apps/settings/tests/SetupChecks/SecurityHeadersTest.php index 17e631b0025..1f75907d427 100644 --- a/apps/settings/tests/SetupChecks/SecurityHeadersTest.php +++ b/apps/settings/tests/SetupChecks/SecurityHeadersTest.php @@ -106,9 +106,7 @@ class SecurityHeadersTest extends TestCase { ]; } - /** - * @dataProvider dataSuccess - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSuccess')] public function testSuccess(array $headers): void { $headers = array_merge( [ @@ -147,9 +145,7 @@ class SecurityHeadersTest extends TestCase { ]; } - /** - * @dataProvider dataFailure - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataFailure')] public function testFailure(array $headers, string $msg): void { $headers = array_merge( [ diff --git a/apps/settings/tests/SetupChecks/WellKnownUrlsTest.php b/apps/settings/tests/SetupChecks/WellKnownUrlsTest.php index 14473a540ba..d55835d66fc 100644 --- a/apps/settings/tests/SetupChecks/WellKnownUrlsTest.php +++ b/apps/settings/tests/SetupChecks/WellKnownUrlsTest.php @@ -96,8 +96,8 @@ class WellKnownUrlsTest extends TestCase { /** * Test responses - * @dataProvider dataTestResponses */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestResponses')] public function testResponses($responses, string $expectedSeverity): void { $this->config ->expects($this->once()) diff --git a/apps/settings/tests/UserMigration/AccountMigratorTest.php b/apps/settings/tests/UserMigration/AccountMigratorTest.php index ded905d226c..b8f8301f777 100644 --- a/apps/settings/tests/UserMigration/AccountMigratorTest.php +++ b/apps/settings/tests/UserMigration/AccountMigratorTest.php @@ -85,9 +85,7 @@ class AccountMigratorTest extends TestCase { ); } - /** - * @dataProvider dataImportExportAccount - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataImportExportAccount')] public function testImportExportAccount(string $userId, array $importData, string $avatarPath, array $importConfig): void { $user = $this->userManager->createUser($userId, 'topsecretpassword'); $avatarExt = pathinfo($avatarPath, PATHINFO_EXTENSION); diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php index f0a69b5cf7c..8f70516f12c 100644 --- a/apps/sharebymail/tests/ShareByMailProviderTest.php +++ b/apps/sharebymail/tests/ShareByMailProviderTest.php @@ -844,9 +844,7 @@ class ShareByMailProviderTest extends TestCase { ]; } - /** - * @dataProvider dataUpdateSendPassword - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataUpdateSendPassword')] public function testUpdateSendPassword(?string $plainTextPassword, string $originalPassword, string $newPassword, bool $originalSendPasswordByTalk, bool $newSendPasswordByTalk, bool $sendMail): void { $node = $this->createMock(File::class); $node->expects($this->any())->method('getName')->willReturn('filename'); diff --git a/apps/testing/lib/HiddenGroupBackend.php b/apps/testing/lib/HiddenGroupBackend.php index 4f7004aae0a..96ead46c06e 100644 --- a/apps/testing/lib/HiddenGroupBackend.php +++ b/apps/testing/lib/HiddenGroupBackend.php @@ -13,12 +13,9 @@ use OCP\Group\Backend\ABackend; use OCP\Group\Backend\IHideFromCollaborationBackend; class HiddenGroupBackend extends ABackend implements IHideFromCollaborationBackend { - private string $groupName; - public function __construct( - string $groupName = 'hidden_group', + private string $groupName = 'hidden_group', ) { - $this->groupName = $groupName; } public function inGroup($uid, $gid): bool { diff --git a/apps/theming/tests/CapabilitiesTest.php b/apps/theming/tests/CapabilitiesTest.php index 16cc6d51ba9..aa08a45a28b 100644 --- a/apps/theming/tests/CapabilitiesTest.php +++ b/apps/theming/tests/CapabilitiesTest.php @@ -128,9 +128,9 @@ class CapabilitiesTest extends TestCase { } /** - * @dataProvider dataGetCapabilities * @param non-empty-array<string, string> $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetCapabilities')] public function testGetCapabilities(string $name, string $url, string $slogan, string $color, string $textColor, string $logo, string $background, string $backgroundColor, string $backgroundTextColor, string $baseUrl, bool $backgroundThemed, array $expected): void { $this->config->expects($this->once()) ->method('getAppValue') diff --git a/apps/theming/tests/Controller/IconControllerTest.php b/apps/theming/tests/Controller/IconControllerTest.php index 329ad429bc5..c5034600e03 100644 --- a/apps/theming/tests/Controller/IconControllerTest.php +++ b/apps/theming/tests/Controller/IconControllerTest.php @@ -95,13 +95,13 @@ class IconControllerTest extends TestCase { $this->imageManager->expects($this->once()) ->method('getImage', false) ->with('favicon') - ->will($this->throwException(new NotFoundException())); + ->willThrowException(new NotFoundException()); $this->imageManager->expects($this->any()) ->method('shouldReplaceIcons') ->willReturn(true); $this->imageManager->expects($this->once()) ->method('getCachedImage') - ->will($this->throwException(new NotFoundException())); + ->willThrowException(new NotFoundException()); $this->iconBuilder->expects($this->once()) ->method('getFavicon') ->with('core') @@ -119,7 +119,7 @@ class IconControllerTest extends TestCase { $this->imageManager->expects($this->once()) ->method('getImage') ->with('favicon', false) - ->will($this->throwException(new NotFoundException())); + ->willThrowException(new NotFoundException()); $this->imageManager->expects($this->any()) ->method('shouldReplaceIcons') ->willReturn(false); @@ -144,7 +144,7 @@ class IconControllerTest extends TestCase { $this->imageManager->expects($this->once()) ->method('getImage') - ->will($this->throwException(new NotFoundException())); + ->willThrowException(new NotFoundException()); $this->imageManager->expects($this->any()) ->method('shouldReplaceIcons') ->willReturn(true); @@ -155,7 +155,7 @@ class IconControllerTest extends TestCase { $file = $this->iconFileMock('filename', 'filecontent'); $this->imageManager->expects($this->once()) ->method('getCachedImage') - ->will($this->throwException(new NotFoundException())); + ->willThrowException(new NotFoundException()); $this->imageManager->expects($this->once()) ->method('setCachedImage') ->willReturn($file); @@ -169,7 +169,7 @@ class IconControllerTest extends TestCase { $this->imageManager->expects($this->once()) ->method('getImage') ->with('favicon') - ->will($this->throwException(new NotFoundException())); + ->willThrowException(new NotFoundException()); $this->imageManager->expects($this->any()) ->method('shouldReplaceIcons') ->willReturn(false); diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php index 39debcef45f..fb461f03a28 100644 --- a/apps/theming/tests/Controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -97,9 +97,7 @@ class ThemingControllerTest extends TestCase { ]; } - /** - * @dataProvider dataUpdateStylesheetSuccess - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataUpdateStylesheetSuccess')] public function testUpdateStylesheetSuccess(string $setting, string $value, string $message): void { $this->themingDefaults ->expects($this->once()) @@ -155,9 +153,7 @@ class ThemingControllerTest extends TestCase { ]; } - /** - * @dataProvider dataUpdateStylesheetError - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataUpdateStylesheetError')] public function testUpdateStylesheetError(string $setting, string $value, string $message): void { $this->themingDefaults ->expects($this->never()) @@ -346,9 +342,7 @@ class ThemingControllerTest extends TestCase { ]; } - /** - * @dataProvider dataUpdateImages - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataUpdateImages')] public function testUpdateLogoNormalLogoUpload(string $mimeType, bool $folderExists = true): void { $tmpLogo = Server::get(ITempManager::class)->getTemporaryFolder() . '/logo.svg'; $destination = Server::get(ITempManager::class)->getTemporaryFolder(); @@ -504,9 +498,7 @@ class ThemingControllerTest extends TestCase { ]; } - /** - * @dataProvider dataPhpUploadErrors - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataPhpUploadErrors')] public function testUpdateLogoLoginScreenUploadWithInvalidImageUpload(int $error, string $expectedErrorMessage): void { $this->request ->expects($this->once()) @@ -543,9 +535,7 @@ class ThemingControllerTest extends TestCase { $this->assertEquals($expected, $this->themingController->uploadImage()); } - /** - * @dataProvider dataPhpUploadErrors - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataPhpUploadErrors')] public function testUpdateLogoUploadWithInvalidImageUpload($error, $expectedErrorMessage): void { $this->request ->expects($this->once()) @@ -614,9 +604,7 @@ class ThemingControllerTest extends TestCase { ]; } - /** - * @dataProvider dataUndoDelete - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataUndoDelete')] public function testUndoDelete(string $value, string $filename): void { $this->l10n ->expects($this->once()) @@ -716,9 +704,7 @@ class ThemingControllerTest extends TestCase { ]; } - /** - * @dataProvider dataGetManifest - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetManifest')] public function testGetManifest(bool $standalone): void { $this->config ->expects($this->once()) diff --git a/apps/theming/tests/Controller/UserThemeControllerTest.php b/apps/theming/tests/Controller/UserThemeControllerTest.php index b830bb5b065..9a8c1cd19aa 100644 --- a/apps/theming/tests/Controller/UserThemeControllerTest.php +++ b/apps/theming/tests/Controller/UserThemeControllerTest.php @@ -92,9 +92,7 @@ class UserThemeControllerTest extends TestCase { ]; } - /** - * @dataProvider dataTestThemes - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestThemes')] public function testEnableTheme(string $themeId, ?string $exception = null): void { $this->themesService ->expects($this->any()) @@ -109,9 +107,7 @@ class UserThemeControllerTest extends TestCase { $this->assertEquals($expected, $this->userThemeController->enableTheme($themeId)); } - /** - * @dataProvider dataTestThemes - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestThemes')] public function testDisableTheme(string $themeId, ?string $exception = null): void { $this->themesService ->expects($this->any()) diff --git a/apps/theming/tests/IconBuilderTest.php b/apps/theming/tests/IconBuilderTest.php index 5eb75e7e694..d881e4eb75c 100644 --- a/apps/theming/tests/IconBuilderTest.php +++ b/apps/theming/tests/IconBuilderTest.php @@ -63,9 +63,7 @@ class IconBuilderTest extends TestCase { ]; } - /** - * @dataProvider dataRenderAppIcon - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataRenderAppIcon')] public function testRenderAppIcon(string $app, string $color, string $file): void { $this->checkImagick(); $this->themingDefaults->expects($this->once()) @@ -89,9 +87,7 @@ class IconBuilderTest extends TestCase { // cloud be something like $expectedIcon->compareImages($icon, Imagick::METRIC_MEANABSOLUTEERROR)[1]) } - /** - * @dataProvider dataRenderAppIcon - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataRenderAppIcon')] public function testGetTouchIcon(string $app, string $color, string $file): void { $this->checkImagick(); $this->themingDefaults->expects($this->once()) @@ -116,9 +112,7 @@ class IconBuilderTest extends TestCase { // cloud be something like $expectedIcon->compareImages($icon, Imagick::METRIC_MEANABSOLUTEERROR)[1]) } - /** - * @dataProvider dataRenderAppIcon - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataRenderAppIcon')] public function testGetFavicon(string $app, string $color, string $file): void { $this->checkImagick(); $this->imageManager->expects($this->once()) diff --git a/apps/theming/tests/ImageManagerTest.php b/apps/theming/tests/ImageManagerTest.php index c9b930ca8c9..0c4d555cc00 100644 --- a/apps/theming/tests/ImageManagerTest.php +++ b/apps/theming/tests/ImageManagerTest.php @@ -221,7 +221,7 @@ class ImageManagerTest extends TestCase { $folder->expects($this->once()) ->method('getFile') ->with('filename') - ->will($this->throwException(new NotFoundException())); + ->willThrowException(new NotFoundException()); $image = $this->imageManager->getCachedImage('filename'); } @@ -313,9 +313,7 @@ class ImageManagerTest extends TestCase { ]; } - /** - * @dataProvider dataUpdateImage - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataUpdateImage')] public function testUpdateImage(string $key, string $tmpFile, bool $folderExists, bool $shouldConvert): void { $file = $this->createMock(ISimpleFile::class); $folder = $this->createMock(ISimpleFolder::class); diff --git a/apps/theming/tests/Service/ThemesServiceTest.php b/apps/theming/tests/Service/ThemesServiceTest.php index a2c3111fbd1..354ed1dec85 100644 --- a/apps/theming/tests/Service/ThemesServiceTest.php +++ b/apps/theming/tests/Service/ThemesServiceTest.php @@ -126,11 +126,11 @@ class ThemesServiceTest extends TestCase { } /** - * @dataProvider dataTestEnableTheme * * @param string[] $enabledThemes * @param string[] $expectedEnabled */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestEnableTheme')] public function testEnableTheme(string $toEnable, array $enabledThemes, array $expectedEnabled): void { $user = $this->createMock(IUser::class); $this->userSession->expects($this->any()) @@ -159,11 +159,11 @@ class ThemesServiceTest extends TestCase { } /** - * @dataProvider dataTestDisableTheme * * @param string[] $enabledThemes * @param string[] $expectedEnabled */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestDisableTheme')] public function testDisableTheme(string $toDisable, array $enabledThemes, array $expectedEnabled): void { $user = $this->createMock(IUser::class); $this->userSession->expects($this->any()) @@ -193,10 +193,9 @@ class ThemesServiceTest extends TestCase { } /** - * @dataProvider dataTestIsEnabled - * * @param string[] $enabledThemes */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestIsEnabled')] public function testIsEnabled(string $themeId, array $enabledThemes, bool $expected): void { $user = $this->createMock(IUser::class); $this->userSession->expects($this->any()) @@ -270,11 +269,11 @@ class ThemesServiceTest extends TestCase { } /** - * @dataProvider dataTestSetEnabledThemes * * @param string[] $enabledThemes * @param string[] $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSetEnabledThemes')] public function testSetEnabledThemes(array $enabledThemes, array $expected): void { $user = $this->createMock(IUser::class); $this->userSession->expects($this->any()) diff --git a/apps/theming/tests/ServicesTest.php b/apps/theming/tests/ServicesTest.php index c9b9a44be0b..3971c9b6698 100644 --- a/apps/theming/tests/ServicesTest.php +++ b/apps/theming/tests/ServicesTest.php @@ -60,9 +60,7 @@ class ServicesTest extends TestCase { ]; } - /** - * @dataProvider queryData - */ + #[\PHPUnit\Framework\Attributes\DataProvider('queryData')] public function testContainerQuery(string $service, ?string $expected = null): void { if ($expected === null) { $expected = $service; diff --git a/apps/theming/tests/Settings/PersonalTest.php b/apps/theming/tests/Settings/PersonalTest.php index e70ef623809..9216450ec9c 100644 --- a/apps/theming/tests/Settings/PersonalTest.php +++ b/apps/theming/tests/Settings/PersonalTest.php @@ -87,10 +87,9 @@ class PersonalTest extends TestCase { } /** - * @dataProvider dataTestGetForm - * * @param string[] $enabledThemes */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetForm')] public function testGetForm(string $enforcedTheme, array $themesState): void { $this->config->expects($this->once()) ->method('getSystemValueString') diff --git a/apps/theming/tests/Themes/AccessibleThemeTestCase.php b/apps/theming/tests/Themes/AccessibleThemeTestCase.php index f3dc2ed53b4..f516e1f5116 100644 --- a/apps/theming/tests/Themes/AccessibleThemeTestCase.php +++ b/apps/theming/tests/Themes/AccessibleThemeTestCase.php @@ -147,9 +147,7 @@ class AccessibleThemeTestCase extends TestCase { ]; } - /** - * @dataProvider dataAccessibilityPairs - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataAccessibilityPairs')] public function testAccessibilityOfVariables(array $mainColors, array $backgroundColors, float $minContrast): void { if (!isset($this->theme)) { $this->markTestSkipped('You need to setup $this->theme in your setUp function'); diff --git a/apps/theming/tests/Themes/DyslexiaFontTest.php b/apps/theming/tests/Themes/DyslexiaFontTest.php index ba27ab592f7..7d56fb4b1be 100644 --- a/apps/theming/tests/Themes/DyslexiaFontTest.php +++ b/apps/theming/tests/Themes/DyslexiaFontTest.php @@ -146,11 +146,10 @@ class DyslexiaFontTest extends TestCase { } /** - * @dataProvider dataTestGetCustomCss - * * Ensure the fonts are always loaded from the web root * despite having url rewriting enabled or not */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetCustomCss')] public function testGetCustomCss(string $webRoot, bool $prettyUrlsEnabled): void { \OC::$WEBROOT = $webRoot; $this->config->expects($this->any()) diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php index 2a0fee6cf16..1acd12f12fa 100644 --- a/apps/theming/tests/ThemingDefaultsTest.php +++ b/apps/theming/tests/ThemingDefaultsTest.php @@ -183,9 +183,7 @@ class ThemingDefaultsTest extends TestCase { ]; } - /** - * @dataProvider legalUrlProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('legalUrlProvider')] public function testGetImprintURL(string $imprintUrl): void { $this->config ->expects($this->once()) @@ -196,9 +194,7 @@ class ThemingDefaultsTest extends TestCase { $this->assertEquals($imprintUrl, $this->template->getImprintUrl()); } - /** - * @dataProvider legalUrlProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('legalUrlProvider')] public function testGetPrivacyURL(string $privacyUrl): void { $this->config ->expects($this->once()) @@ -346,9 +342,7 @@ class ThemingDefaultsTest extends TestCase { ]; } - /** - * @dataProvider invalidLegalUrlProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('invalidLegalUrlProvider')] public function testGetShortFooterInvalidImprint(string $invalidImprintUrl): void { $this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]); $this->config @@ -365,9 +359,7 @@ class ThemingDefaultsTest extends TestCase { $this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan', $this->template->getShortFooter()); } - /** - * @dataProvider invalidLegalUrlProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('invalidLegalUrlProvider')] public function testGetShortFooterInvalidPrivacy(string $invalidPrivacyUrl): void { $this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]); $this->config @@ -455,9 +447,7 @@ class ThemingDefaultsTest extends TestCase { ]; } - /** - * @dataProvider dataGetColorPrimary - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetColorPrimary')] public function testGetColorPrimary(bool $disableTheming, string $primaryColor, string $userPrimaryColor, string $expected): void { $user = $this->createMock(IUser::class); $this->userSession->expects($this->any()) @@ -798,9 +788,7 @@ class ThemingDefaultsTest extends TestCase { ]; } - /** - * @dataProvider dataReplaceImagePath - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataReplaceImagePath')] public function testReplaceImagePath(string $app, string $image, string|bool $result = 'themingRoute?v=1234abcd'): void { $this->cache->expects($this->any()) ->method('get') diff --git a/apps/theming/tests/UtilTest.php b/apps/theming/tests/UtilTest.php index c0629e425e7..1e944027e32 100644 --- a/apps/theming/tests/UtilTest.php +++ b/apps/theming/tests/UtilTest.php @@ -48,9 +48,7 @@ class UtilTest extends TestCase { ]; } - /** - * @dataProvider dataColorContrast - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataColorContrast')] public function testColorContrast(string $color1, string $color2, int|float $contrast): void { $this->assertEqualsWithDelta($contrast, $this->util->colorContrast($color1, $color2), .001); } @@ -63,9 +61,7 @@ class UtilTest extends TestCase { ['#ffff00', true], ]; } - /** - * @dataProvider dataInvertTextColor - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataInvertTextColor')] public function testInvertTextColor(string $color, bool $expected): void { $invert = $this->util->invertTextColor($color); $this->assertEquals($expected, $invert); @@ -143,9 +139,7 @@ class UtilTest extends TestCase { $this->assertEquals($expected, $button); } - /** - * @dataProvider dataGetAppIcon - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetAppIcon')] public function testGetAppIcon(string $app, string $expected): void { $this->appData->expects($this->any()) ->method('getFolder') @@ -178,9 +172,7 @@ class UtilTest extends TestCase { $this->assertEquals($file, $icon); } - /** - * @dataProvider dataGetAppImage - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetAppImage')] public function testGetAppImage(string $app, string $image, string|bool $expected): void { $this->assertEquals($expected, $this->util->getAppImage($app, $image)); } @@ -226,9 +218,7 @@ class UtilTest extends TestCase { ['backgroundColor', false], ]; } - /** - * @dataProvider dataIsBackgroundThemed - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataIsBackgroundThemed')] public function testIsBackgroundThemed(string $backgroundMime, bool $expected): void { $this->config->expects($this->once()) ->method('getAppValue') diff --git a/apps/twofactor_backupcodes/tests/Unit/Activity/ProviderTest.php b/apps/twofactor_backupcodes/tests/Unit/Activity/ProviderTest.php index a3c6d15902a..152ff80194a 100644 --- a/apps/twofactor_backupcodes/tests/Unit/Activity/ProviderTest.php +++ b/apps/twofactor_backupcodes/tests/Unit/Activity/ProviderTest.php @@ -51,9 +51,7 @@ class ProviderTest extends TestCase { ]; } - /** - * @dataProvider subjectData - */ + #[\PHPUnit\Framework\Attributes\DataProvider('subjectData')] public function testParse(string $subject): void { $lang = 'ru'; $event = $this->createMock(IEvent::class); diff --git a/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php b/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php index 51237cf012e..26a5ecde052 100644 --- a/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php +++ b/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php @@ -152,9 +152,7 @@ class UpdateAvailableNotificationsTest extends TestCase { ]; } - /** - * @dataProvider dataCheckCoreUpdate - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataCheckCoreUpdate')] public function testCheckCoreUpdate(string $channel, mixed $versionCheck, mixed $version, ?string $readableVersion, ?int $errorDays): void { $job = $this->getJob([ 'createNotifications', @@ -231,9 +229,7 @@ class UpdateAvailableNotificationsTest extends TestCase { ]; } - /** - * @dataProvider dataCheckAppUpdates - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataCheckAppUpdates')] public function testCheckAppUpdates(array $apps, array $isUpdateAvailable, array $notifications): void { $job = $this->getJob([ 'isUpdateAvailable', @@ -268,9 +264,7 @@ class UpdateAvailableNotificationsTest extends TestCase { ]; } - /** - * @dataProvider dataCreateNotifications - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataCreateNotifications')] public function testCreateNotifications(string $app, string $version, string|false $lastNotification, string|false $callDelete, bool $createNotification, ?array $users, ?array $userNotifications): void { $job = $this->getJob([ 'deleteOutdatedNotifications', @@ -351,9 +345,7 @@ class UpdateAvailableNotificationsTest extends TestCase { ]; } - /** - * @dataProvider dataGetUsersToNotify - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetUsersToNotify')] public function testGetUsersToNotify(array $groups, array $groupUsers, array $expected): void { $job = $this->getJob(); @@ -394,10 +386,10 @@ class UpdateAvailableNotificationsTest extends TestCase { } /** - * @dataProvider dataDeleteOutdatedNotifications * @param string $app * @param string $version */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataDeleteOutdatedNotifications')] public function testDeleteOutdatedNotifications(string $app, string $version): void { $notification = $this->createMock(INotification::class); $notification->expects($this->once()) diff --git a/apps/updatenotification/tests/Controller/APIControllerTest.php b/apps/updatenotification/tests/Controller/APIControllerTest.php index 3c3764248ef..84973e64c22 100644 --- a/apps/updatenotification/tests/Controller/APIControllerTest.php +++ b/apps/updatenotification/tests/Controller/APIControllerTest.php @@ -55,9 +55,7 @@ class APIControllerTest extends TestCase { ); } - /** - * @dataProvider dataGetAppChangelog - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetAppChangelog')] public function testGetAppChangelogEntry( array $params, bool $hasChanges, diff --git a/apps/updatenotification/tests/Notification/NotifierTest.php b/apps/updatenotification/tests/Notification/NotifierTest.php index 6d47d0c6b89..aab5a84d6f3 100644 --- a/apps/updatenotification/tests/Notification/NotifierTest.php +++ b/apps/updatenotification/tests/Notification/NotifierTest.php @@ -89,9 +89,7 @@ class NotifierTest extends TestCase { ]; } - /** - * @dataProvider dataUpdateAlreadyInstalledCheck - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataUpdateAlreadyInstalledCheck')] public function testUpdateAlreadyInstalledCheck(string $versionNotification, string $versionInstalled, bool $exception): void { $notifier = $this->getNotifier(); diff --git a/apps/updatenotification/tests/Settings/AdminTest.php b/apps/updatenotification/tests/Settings/AdminTest.php index cb815bc8b69..0429c628049 100644 --- a/apps/updatenotification/tests/Settings/AdminTest.php +++ b/apps/updatenotification/tests/Settings/AdminTest.php @@ -448,9 +448,7 @@ class AdminTest extends TestCase { ]; } - /** - * @dataProvider changesProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('changesProvider')] public function testFilterChanges($changes, $userLang, $expectation): void { $iterator = $this->createMock(ILanguageIterator::class); $iterator->expects($this->any()) diff --git a/apps/user_ldap/tests/AccessTest.php b/apps/user_ldap/tests/AccessTest.php index eafaeb76403..54be29d0f86 100644 --- a/apps/user_ldap/tests/AccessTest.php +++ b/apps/user_ldap/tests/AccessTest.php @@ -132,10 +132,10 @@ class AccessTest extends TestCase { } /** - * @dataProvider convertSID2StrSuccessData * @param array $sidArray * @param $sidExpected */ + #[\PHPUnit\Framework\Attributes\DataProvider('convertSID2StrSuccessData')] public function testConvertSID2StrSuccess(array $sidArray, $sidExpected): void { $sidBinary = implode('', $sidArray); $this->assertSame($sidExpected, $this->access->convertSID2Str($sidBinary)); @@ -219,9 +219,7 @@ class AccessTest extends TestCase { ]; } - /** - * @dataProvider dnInputDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dnInputDataProvider')] public function testStringResemblesDN(string $input, array|bool $interResult, bool $expectedResult): void { [$lw, $con, $um, $helper] = $this->getConnectorAndLdapMock(); /** @var IConfig&MockObject $config */ @@ -240,9 +238,7 @@ class AccessTest extends TestCase { $this->assertSame($expectedResult, $access->stringResemblesDN($input)); } - /** - * @dataProvider dnInputDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dnInputDataProvider')] public function testStringResemblesDNLDAPmod(string $input, array|bool $interResult, bool $expectedResult): void { [, $con, $um, $helper] = $this->getConnectorAndLdapMock(); /** @var IConfig&MockObject $config */ @@ -414,9 +410,7 @@ class AccessTest extends TestCase { ]; } - /** - * @dataProvider dNAttributeProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dNAttributeProvider')] public function testSanitizeDN(string $attribute): void { [$lw, $con, $um, $helper] = $this->getConnectorAndLdapMock(); /** @var IConfig&MockObject $config */ @@ -698,9 +692,7 @@ class AccessTest extends TestCase { ]; } - /** - * @dataProvider intUsernameProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('intUsernameProvider')] public function testSanitizeUsername(string $name, ?string $expected): void { if ($expected === null) { $this->expectException(\InvalidArgumentException::class); @@ -709,9 +701,7 @@ class AccessTest extends TestCase { $this->assertSame($expected, $sanitizedName); } - /** - * @dataProvider groupIDCandidateProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('groupIDCandidateProvider')] public function testSanitizeGroupIDCandidate(string $name, string $expected): void { $sanitizedName = $this->access->sanitizeGroupIDCandidate($name); $this->assertSame($expected, $sanitizedName); diff --git a/apps/user_ldap/tests/ConfigurationTest.php b/apps/user_ldap/tests/ConfigurationTest.php index dd6bd020f7b..db92598fcfd 100644 --- a/apps/user_ldap/tests/ConfigurationTest.php +++ b/apps/user_ldap/tests/ConfigurationTest.php @@ -86,9 +86,7 @@ class ConfigurationTest extends \Test\TestCase { ]; } - /** - * @dataProvider configurationDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('configurationDataProvider')] public function testSetValue(string $key, string|array $input, string|array $expected): void { $this->configuration->setConfiguration([$key => $input]); $this->assertSame($this->configuration->$key, $expected); @@ -105,17 +103,13 @@ class ConfigurationTest extends \Test\TestCase { ]; } - /** - * @dataProvider avatarRuleValueProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('avatarRuleValueProvider')] public function testGetAvatarAttributes(string $setting, array $expected): void { $this->configuration->setConfiguration(['ldapUserAvatarRule' => $setting]); $this->assertSame($expected, $this->configuration->getAvatarAttributes()); } - /** - * @dataProvider avatarRuleValueProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('avatarRuleValueProvider')] public function testResolveRule(string $setting, array $expected): void { $this->configuration->setConfiguration(['ldapUserAvatarRule' => $setting]); // so far the only thing that can get resolved :) diff --git a/apps/user_ldap/tests/ConnectionTest.php b/apps/user_ldap/tests/ConnectionTest.php index 601611fcc2f..7116e15898f 100644 --- a/apps/user_ldap/tests/ConnectionTest.php +++ b/apps/user_ldap/tests/ConnectionTest.php @@ -101,8 +101,7 @@ class ConnectionTest extends \Test\TestCase { // Not called often enough? Then, the fallback to the backup server is broken. $this->connection->expects($this->exactly(2)) ->method('getFromCache') - ->with('overrideMainServer') - ->will($this->onConsecutiveCalls(false, false, true, true)); + ->with('overrideMainServer')->willReturnOnConsecutiveCalls(false, false, true, true); $this->connection->expects($this->once()) ->method('writeToCache') diff --git a/apps/user_ldap/tests/Group_LDAPTest.php b/apps/user_ldap/tests/Group_LDAPTest.php index d2634548f4f..10182111768 100644 --- a/apps/user_ldap/tests/Group_LDAPTest.php +++ b/apps/user_ldap/tests/Group_LDAPTest.php @@ -475,9 +475,7 @@ class Group_LDAPTest extends TestCase { ]; } - /** - * @dataProvider groupWithMembersProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('groupWithMembersProvider')] public function testInGroupMember(string $gid, string $groupDn, array $memberDNs): void { $uid = 'someUser'; $userDn = $memberDNs[0]; @@ -516,9 +514,7 @@ class Group_LDAPTest extends TestCase { $this->assertTrue($this->groupBackend->inGroup($uid, $gid)); } - /** - * @dataProvider groupWithMembersProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('groupWithMembersProvider')] public function testInGroupMemberNot(string $gid, string $groupDn, array $memberDNs): void { $uid = 'unelatedUser'; $userDn = 'uid=unrelatedUser,ou=unrelatedTeam,ou=unrelatedDepartment,dc=someDomain,dc=someTld'; @@ -557,9 +553,7 @@ class Group_LDAPTest extends TestCase { $this->assertFalse($this->groupBackend->inGroup($uid, $gid)); } - /** - * @dataProvider groupWithMembersProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('groupWithMembersProvider')] public function testInGroupMemberUid(string $gid, string $groupDn, array $memberDNs): void { $memberUids = []; $userRecords = []; @@ -767,8 +761,7 @@ class Group_LDAPTest extends TestCase { ->method('username2dn') ->willReturn($dn); $this->access->expects($this->exactly(5)) - ->method('readAttribute') - ->will($this->onConsecutiveCalls($expectedGroups, [], [], [], [])); + ->method('readAttribute')->willReturnOnConsecutiveCalls($expectedGroups, [], [], [], []); $this->access->expects($this->any()) ->method('dn2groupname') ->willReturnArgument(0); @@ -947,9 +940,7 @@ class Group_LDAPTest extends TestCase { ]; } - /** - * @dataProvider nestedGroupsProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('nestedGroupsProvider')] public function testGetGroupsByMember(bool $nestedGroups): void { $groupFilter = '(&(objectclass=nextcloudGroup)(nextcloudEnabled=TRUE))'; $this->access->connection->expects($this->any()) @@ -1321,9 +1312,7 @@ class Group_LDAPTest extends TestCase { ]; } - /** - * @dataProvider groupMemberProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('groupMemberProvider')] public function testGroupMembers(array $expectedResult, array $groupsInfo): void { $this->access->expects($this->any()) ->method('readAttribute') @@ -1362,9 +1351,7 @@ class Group_LDAPTest extends TestCase { ]; } - /** - * @dataProvider displayNameProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('displayNameProvider')] public function testGetDisplayName(string $expected, bool|array $ldapResult): void { $gid = 'graphic_novelists'; diff --git a/apps/user_ldap/tests/Jobs/CleanUpTest.php b/apps/user_ldap/tests/Jobs/CleanUpTest.php index cefc9cc86b5..5a1e563a1e8 100644 --- a/apps/user_ldap/tests/Jobs/CleanUpTest.php +++ b/apps/user_ldap/tests/Jobs/CleanUpTest.php @@ -61,7 +61,7 @@ class CleanUpTest extends TestCase { public function test_runNotAllowedByBrokenHelper(): void { $this->mocks['helper']->expects($this->once()) ->method('haveDisabledConfigurations') - ->will($this->throwException(new Exception())); + ->willThrowException(new Exception()); $this->mocks['ocConfig']->expects($this->never()) ->method('getSystemValue'); diff --git a/apps/user_ldap/tests/Jobs/SyncTest.php b/apps/user_ldap/tests/Jobs/SyncTest.php index 20489ea0901..f6ecf984ab0 100644 --- a/apps/user_ldap/tests/Jobs/SyncTest.php +++ b/apps/user_ldap/tests/Jobs/SyncTest.php @@ -102,9 +102,7 @@ class SyncTest extends TestCase { ]; } - /** - * @dataProvider intervalDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('intervalDataProvider')] public function testUpdateInterval(int $userCount, int $pagingSize1, int $pagingSize2): void { $this->config->expects($this->once()) ->method('setAppValue') @@ -145,9 +143,7 @@ class SyncTest extends TestCase { ]; } - /** - * @dataProvider moreResultsProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('moreResultsProvider')] public function testMoreResults($pagingSize, $results, $expected): void { $connection = $this->getMockBuilder(Connection::class) ->setConstructorArgs([ @@ -204,9 +200,7 @@ class SyncTest extends TestCase { ]; } - /** - * @dataProvider cycleDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('cycleDataProvider')] public function testDetermineNextCycle(?array $cycleData, array $prefixes, ?array $expectedCycle): void { $this->helper->expects($this->any()) ->method('getServerConfigurationPrefixes') @@ -220,7 +214,7 @@ class SyncTest extends TestCase { ]; $this->config->expects($this->exactly(2)) ->method('setAppValue') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); @@ -284,9 +278,7 @@ class SyncTest extends TestCase { ]; } - /** - * @dataProvider runDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('runDataProvider')] public function testRun(array $runData): void { $this->config->expects($this->any()) ->method('getAppValue') @@ -322,7 +314,7 @@ class SyncTest extends TestCase { ]; $this->config->expects($this->exactly(3)) ->method('setAppValue') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); diff --git a/apps/user_ldap/tests/LDAPTest.php b/apps/user_ldap/tests/LDAPTest.php index 936a1a27d3d..6da592ad6a1 100644 --- a/apps/user_ldap/tests/LDAPTest.php +++ b/apps/user_ldap/tests/LDAPTest.php @@ -33,9 +33,7 @@ class LDAPTest extends TestCase { ]; } - /** - * @dataProvider errorProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('errorProvider')] public function testSearchWithErrorHandler(string $errorMessage, bool $passThrough): void { $wasErrorHandlerCalled = false; $errorHandler = function ($number, $message, $file, $line) use (&$wasErrorHandlerCalled): void { diff --git a/apps/user_ldap/tests/Migration/UUIDFixInsertTest.php b/apps/user_ldap/tests/Migration/UUIDFixInsertTest.php index 0fc601c7d2e..6215ffcb6a1 100644 --- a/apps/user_ldap/tests/Migration/UUIDFixInsertTest.php +++ b/apps/user_ldap/tests/Migration/UUIDFixInsertTest.php @@ -86,9 +86,7 @@ class UUIDFixInsertTest extends TestCase { ]; } - /** - * @dataProvider recordProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('recordProvider')] public function testRun(array $userBatches, array $groupBatches): void { $this->config->expects($this->once()) ->method('getAppValue') @@ -116,9 +114,7 @@ class UUIDFixInsertTest extends TestCase { $this->job->run($out); } - /** - * @dataProvider recordProviderTooLongAndNone - */ + #[\PHPUnit\Framework\Attributes\DataProvider('recordProviderTooLongAndNone')] public function testRunWithManyAndNone(array $userBatches, array $groupBatches): void { $this->config->expects($this->once()) ->method('getAppValue') diff --git a/apps/user_ldap/tests/Service/BirthdateParserServiceTest.php b/apps/user_ldap/tests/Service/BirthdateParserServiceTest.php index 85d6a6ba5f7..061118f10c1 100644 --- a/apps/user_ldap/tests/Service/BirthdateParserServiceTest.php +++ b/apps/user_ldap/tests/Service/BirthdateParserServiceTest.php @@ -35,9 +35,7 @@ class BirthdateParserServiceTest extends TestCase { ]; } - /** - * @dataProvider parseBirthdateDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('parseBirthdateDataProvider')] public function testParseBirthdate( string $value, ?DateTimeImmutable $expected, diff --git a/apps/user_ldap/tests/User/ManagerTest.php b/apps/user_ldap/tests/User/ManagerTest.php index 3f8b3aa174f..bf9d1f5746f 100644 --- a/apps/user_ldap/tests/User/ManagerTest.php +++ b/apps/user_ldap/tests/User/ManagerTest.php @@ -85,9 +85,7 @@ class ManagerTest extends \Test\TestCase { ]; } - /** - * @dataProvider dnProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dnProvider')] public function testGetByDNExisting(string $inputDN): void { $uid = '563418fc-423b-1033-8d1c-ad5f418ee02e'; @@ -184,9 +182,7 @@ class ManagerTest extends \Test\TestCase { ]; } - /** - * @dataProvider attributeRequestProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('attributeRequestProvider')] public function testGetAttributes($minimal): void { $this->connection->setConfiguration([ 'ldapEmailAttribute' => 'MAIL', diff --git a/apps/user_ldap/tests/User/OfflineUserTest.php b/apps/user_ldap/tests/User/OfflineUserTest.php index 5ef89303111..223e63421ad 100644 --- a/apps/user_ldap/tests/User/OfflineUserTest.php +++ b/apps/user_ldap/tests/User/OfflineUserTest.php @@ -47,9 +47,7 @@ class OfflineUserTest extends TestCase { ]; } - /** - * @dataProvider shareOwnerProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('shareOwnerProvider')] public function testHasActiveShares(array $existingShareTypes, bool $expected): void { $shareMock = $this->createMock(IShare::class); diff --git a/apps/user_ldap/tests/User/UserTest.php b/apps/user_ldap/tests/User/UserTest.php index d9075af1569..00edd8b3f9b 100644 --- a/apps/user_ldap/tests/User/UserTest.php +++ b/apps/user_ldap/tests/User/UserTest.php @@ -780,9 +780,7 @@ class UserTest extends \Test\TestCase { ]; } - /** - * @dataProvider extStorageHomeDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('extStorageHomeDataProvider')] public function testUpdateExtStorageHome(string $expected, ?string $valueFromLDAP = null, bool $isSet = true): void { if ($valueFromLDAP === null) { $this->connection->expects($this->once()) @@ -936,9 +934,7 @@ class UserTest extends \Test\TestCase { ]; } - /** - * @dataProvider emptyHomeFolderAttributeValueProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('emptyHomeFolderAttributeValueProvider')] public function testGetHomePathNotConfigured(string $attributeValue): void { $this->connection->expects($this->any()) ->method('__get') @@ -1012,9 +1008,7 @@ class UserTest extends \Test\TestCase { ]; } - /** - * @dataProvider displayNameProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('displayNameProvider')] public function testComposeAndStoreDisplayName(string $part1, string $part2, string $expected, bool $expectTriggerChange): void { $this->config->expects($this->once()) ->method('setUserValue'); diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php index 5be01d5e414..f8900c3cca4 100644 --- a/apps/user_ldap/tests/User_LDAPTest.php +++ b/apps/user_ldap/tests/User_LDAPTest.php @@ -1325,9 +1325,7 @@ class User_LDAPTest extends TestCase { ]; } - /** - * @dataProvider avatarDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('avatarDataProvider')] public function testCanChangeAvatar(string|bool $imageData, bool $expected): void { $isValidImage = str_starts_with((string)$imageData, 'valid'); @@ -1452,9 +1450,7 @@ class User_LDAPTest extends TestCase { ]; } - /** - * @dataProvider actionProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('actionProvider')] public function testImplementsAction(string $configurable, string|int $value, int $actionCode, bool $expected): void { $this->pluginManager->expects($this->once()) ->method('getImplementedActions') diff --git a/apps/user_status/tests/Unit/CapabilitiesTest.php b/apps/user_status/tests/Unit/CapabilitiesTest.php index ef721eaa90b..f07892ff3fd 100644 --- a/apps/user_status/tests/Unit/CapabilitiesTest.php +++ b/apps/user_status/tests/Unit/CapabilitiesTest.php @@ -24,9 +24,7 @@ class CapabilitiesTest extends TestCase { $this->capabilities = new Capabilities($this->emojiHelper); } - /** - * @dataProvider getCapabilitiesDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('getCapabilitiesDataProvider')] public function testGetCapabilities(bool $supportsEmojis): void { $this->emojiHelper->expects($this->once()) ->method('doesPlatformSupportEmoji') diff --git a/apps/user_status/tests/Unit/Controller/UserStatusControllerTest.php b/apps/user_status/tests/Unit/Controller/UserStatusControllerTest.php index 45ee9c4fdba..e99290319ed 100644 --- a/apps/user_status/tests/Unit/Controller/UserStatusControllerTest.php +++ b/apps/user_status/tests/Unit/Controller/UserStatusControllerTest.php @@ -87,9 +87,7 @@ class UserStatusControllerTest extends TestCase { $this->controller->getStatus(); } - /** - * @dataProvider setStatusDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('setStatusDataProvider')] public function testSetStatus( string $statusType, ?string $statusIcon, @@ -149,9 +147,7 @@ class UserStatusControllerTest extends TestCase { ]; } - /** - * @dataProvider setPredefinedMessageDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('setPredefinedMessageDataProvider')] public function testSetPredefinedMessage( string $messageId, ?int $clearAt, @@ -211,9 +207,7 @@ class UserStatusControllerTest extends TestCase { ]; } - /** - * @dataProvider setCustomMessageDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('setCustomMessageDataProvider')] public function testSetCustomMessage( ?string $statusIcon, string $message, diff --git a/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php b/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php index c9bda492210..ea4480489c7 100644 --- a/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php +++ b/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php @@ -134,9 +134,7 @@ class UserStatusMapperTest extends TestCase { $this->mapper->insert($userStatus2); } - /** - * @dataProvider clearStatusesOlderThanDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('clearStatusesOlderThanDataProvider')] public function testClearStatusesOlderThan(string $status, bool $isUserDefined, int $timestamp, bool $expectsClean): void { $oldStatus = UserStatus::fromParams([ 'userId' => 'john.doe', @@ -233,9 +231,7 @@ class UserStatusMapperTest extends TestCase { ]; } - /** - * @dataProvider dataCreateBackupStatus - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataCreateBackupStatus')] public function testCreateBackupStatus(bool $hasStatus, bool $hasBackup, bool $backupCreated): void { if ($hasStatus) { $userStatus1 = new UserStatus(); diff --git a/apps/user_status/tests/Unit/Listener/UserLiveStatusListenerTest.php b/apps/user_status/tests/Unit/Listener/UserLiveStatusListenerTest.php index c94315a7a93..c03eed0089e 100644 --- a/apps/user_status/tests/Unit/Listener/UserLiveStatusListenerTest.php +++ b/apps/user_status/tests/Unit/Listener/UserLiveStatusListenerTest.php @@ -49,9 +49,7 @@ class UserLiveStatusListenerTest extends TestCase { ); } - /** - * @dataProvider handleEventWithCorrectEventDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('handleEventWithCorrectEventDataProvider')] public function testHandleWithCorrectEvent( string $userId, string $previousStatus, diff --git a/apps/user_status/tests/Unit/Service/PredefinedStatusServiceTest.php b/apps/user_status/tests/Unit/Service/PredefinedStatusServiceTest.php index 091466637f0..de5d92055f1 100644 --- a/apps/user_status/tests/Unit/Service/PredefinedStatusServiceTest.php +++ b/apps/user_status/tests/Unit/Service/PredefinedStatusServiceTest.php @@ -93,9 +93,7 @@ class PredefinedStatusServiceTest extends TestCase { ], $actual); } - /** - * @dataProvider getIconForIdDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('getIconForIdDataProvider')] public function testGetIconForId(string $id, ?string $expectedIcon): void { $actual = $this->service->getIconForId($id); $this->assertEquals($expectedIcon, $actual); @@ -113,9 +111,7 @@ class PredefinedStatusServiceTest extends TestCase { ]; } - /** - * @dataProvider getTranslatedStatusForIdDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('getTranslatedStatusForIdDataProvider')] public function testGetTranslatedStatusForId(string $id, ?string $expected): void { $this->l10n->method('t') ->willReturnArgument(0); @@ -136,9 +132,7 @@ class PredefinedStatusServiceTest extends TestCase { ]; } - /** - * @dataProvider isValidIdDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('isValidIdDataProvider')] public function testIsValidId(string $id, bool $expected): void { $actual = $this->service->isValidId($id); $this->assertEquals($expected, $actual); diff --git a/apps/user_status/tests/Unit/Service/StatusServiceTest.php b/apps/user_status/tests/Unit/Service/StatusServiceTest.php index 7aeb1d48448..7dfa5b0d064 100644 --- a/apps/user_status/tests/Unit/Service/StatusServiceTest.php +++ b/apps/user_status/tests/Unit/Service/StatusServiceTest.php @@ -221,9 +221,7 @@ class StatusServiceTest extends TestCase { $this->assertNull($status->getMessageId()); } - /** - * @dataProvider setStatusDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('setStatusDataProvider')] public function testSetStatus( string $userId, string $status, @@ -344,9 +342,7 @@ class StatusServiceTest extends TestCase { ]; } - /** - * @dataProvider setPredefinedMessageDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('setPredefinedMessageDataProvider')] public function testSetPredefinedMessage( string $userId, string $messageId, @@ -433,9 +429,7 @@ class StatusServiceTest extends TestCase { ]; } - /** - * @dataProvider setCustomMessageDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('setCustomMessageDataProvider')] public function testSetCustomMessage( string $userId, ?string $statusIcon, @@ -799,9 +793,7 @@ class StatusServiceTest extends TestCase { ]; } - /** - * @dataProvider dataSetUserStatus - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSetUserStatus')] public function testSetUserStatus(string $messageId, string $oldMessageId, bool $expectedUpdateShortcut): void { $previous = new UserStatus(); $previous->setId(1); diff --git a/apps/webhook_listeners/tests/Service/PHPMongoQueryTest.php b/apps/webhook_listeners/tests/Service/PHPMongoQueryTest.php index e56bdb6a4cf..337b876dfef 100644 --- a/apps/webhook_listeners/tests/Service/PHPMongoQueryTest.php +++ b/apps/webhook_listeners/tests/Service/PHPMongoQueryTest.php @@ -38,9 +38,7 @@ class PHPMongoQueryTest extends TestCase { ]; } - /** - * @dataProvider dataExecuteQuery - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataExecuteQuery')] public function testExecuteQuery(array $query, array $document, bool $matches): void { $this->assertEquals($matches, PHPMongoQuery::executeQuery($query, $document)); } diff --git a/apps/workflowengine/tests/Check/AbstractStringCheckTest.php b/apps/workflowengine/tests/Check/AbstractStringCheckTest.php index d10fcfb4cc3..26d4ccb8553 100644 --- a/apps/workflowengine/tests/Check/AbstractStringCheckTest.php +++ b/apps/workflowengine/tests/Check/AbstractStringCheckTest.php @@ -50,9 +50,7 @@ class AbstractStringCheckTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataExecuteStringCheck - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataExecuteStringCheck')] public function testExecuteStringCheck(string $operation, string $checkValue, string $actualValue, bool $expected): void { $check = $this->getCheckMock(); @@ -69,9 +67,7 @@ class AbstractStringCheckTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataValidateCheck - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataValidateCheck')] public function testValidateCheck(string $operator, string $value): void { $check = $this->getCheckMock(); @@ -90,9 +86,7 @@ class AbstractStringCheckTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataValidateCheckInvalid - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataValidateCheckInvalid')] public function testValidateCheckInvalid(string $operator, string $value, int $exceptionCode, string $exceptionMessage): void { $check = $this->getCheckMock(); @@ -112,9 +106,7 @@ class AbstractStringCheckTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataMatch - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataMatch')] public function testMatch(string $pattern, string $subject, array $matches, bool $expected): void { $check = $this->getCheckMock(); diff --git a/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php b/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php index f2f8026e666..c0e56daefa8 100644 --- a/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php +++ b/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php @@ -44,9 +44,7 @@ class RequestRemoteAddressTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataExecuteCheckIPv4 - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataExecuteCheckIPv4')] public function testExecuteCheckMatchesIPv4(string $value, string $ip, bool $expected): void { $check = new RequestRemoteAddress($this->getL10NMock(), $this->request); @@ -57,9 +55,7 @@ class RequestRemoteAddressTest extends \Test\TestCase { $this->assertEquals($expected, $check->executeCheck('matchesIPv4', $value)); } - /** - * @dataProvider dataExecuteCheckIPv4 - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataExecuteCheckIPv4')] public function testExecuteCheckNotMatchesIPv4(string $value, string $ip, bool $expected): void { $check = new RequestRemoteAddress($this->getL10NMock(), $this->request); @@ -82,9 +78,7 @@ class RequestRemoteAddressTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataExecuteCheckIPv6 - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataExecuteCheckIPv6')] public function testExecuteCheckMatchesIPv6(string $value, string $ip, bool $expected): void { $check = new RequestRemoteAddress($this->getL10NMock(), $this->request); @@ -95,9 +89,7 @@ class RequestRemoteAddressTest extends \Test\TestCase { $this->assertEquals($expected, $check->executeCheck('matchesIPv6', $value)); } - /** - * @dataProvider dataExecuteCheckIPv6 - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataExecuteCheckIPv6')] public function testExecuteCheckNotMatchesIPv6(string $value, string $ip, bool $expected): void { $check = new RequestRemoteAddress($this->getL10NMock(), $this->request); diff --git a/apps/workflowengine/tests/Check/RequestTimeTest.php b/apps/workflowengine/tests/Check/RequestTimeTest.php index 21127d4d56e..a8439b8b9f4 100644 --- a/apps/workflowengine/tests/Check/RequestTimeTest.php +++ b/apps/workflowengine/tests/Check/RequestTimeTest.php @@ -63,9 +63,7 @@ class RequestTimeTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataExecuteCheck - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataExecuteCheck')] public function testExecuteCheckIn(string $value, int $timestamp, bool $expected): void { $check = new RequestTime($this->getL10NMock(), $this->timeFactory); @@ -76,9 +74,7 @@ class RequestTimeTest extends \Test\TestCase { $this->assertEquals($expected, $check->executeCheck('in', $value)); } - /** - * @dataProvider dataExecuteCheck - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataExecuteCheck')] public function testExecuteCheckNotIn(string $value, int $timestamp, bool $expected): void { $check = new RequestTime($this->getL10NMock(), $this->timeFactory); @@ -97,9 +93,7 @@ class RequestTimeTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataValidateCheck - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataValidateCheck')] public function testValidateCheck(string $operator, string $value): void { $check = new RequestTime($this->getL10NMock(), $this->timeFactory); $check->validateCheck($operator, $value); @@ -118,9 +112,7 @@ class RequestTimeTest extends \Test\TestCase { ]; } - /** - * @dataProvider dataValidateCheckInvalid - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataValidateCheckInvalid')] public function testValidateCheckInvalid(string $operator, string $value, int $exceptionCode, string $exceptionMessage): void { $check = new RequestTime($this->getL10NMock(), $this->timeFactory); diff --git a/apps/workflowengine/tests/Check/RequestUserAgentTest.php b/apps/workflowengine/tests/Check/RequestUserAgentTest.php index 2fe96bf3bdb..09eaea6555b 100644 --- a/apps/workflowengine/tests/Check/RequestUserAgentTest.php +++ b/apps/workflowengine/tests/Check/RequestUserAgentTest.php @@ -82,9 +82,7 @@ class RequestUserAgentTest extends TestCase { ]; } - /** - * @dataProvider dataExecuteCheck - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataExecuteCheck')] public function testExecuteCheck(string $operation, string $checkValue, string $actualValue, bool $expected): void { $this->request->expects($this->once()) ->method('getHeader') |