diff --git a/Tests/Functional/Repository/CategoryRepositoryTest.php b/Tests/Functional/Repository/CategoryRepositoryTest.php index 9dc22b626..b3476d8f3 100644 --- a/Tests/Functional/Repository/CategoryRepositoryTest.php +++ b/Tests/Functional/Repository/CategoryRepositoryTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Functional\Repository; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; use DERHANSEN\SfEventMgt\Domain\Model\Dto\CategoryDemand; use DERHANSEN\SfEventMgt\Domain\Repository\CategoryRepository; use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder; @@ -33,18 +35,14 @@ public function setUp(): void $GLOBALS['TYPO3_REQUEST'] = $request; } - /** - * @test - */ + #[Test] public function findRecordsByUid(): void { $events = $this->categoryRepository->findByUid(1); self::assertEquals($events->getTitle(), 'Category 1'); } - /** - * @test - */ + #[Test] public function findDemandedRecordsByStoragePageRestriction(): void { $demand = new CategoryDemand(); @@ -83,12 +81,12 @@ public static function findDemandedRecordsByCategoryDataProvider(): array /** * Test if category restiction works * - * @dataProvider findDemandedRecordsByCategoryDataProvider - * @test * @param mixed $category * @param mixed $includeSubcategory * @param mixed $expected */ + #[DataProvider('findDemandedRecordsByCategoryDataProvider')] + #[Test] public function findDemandedRecordsByCategory($category, $includeSubcategory, $expected): void { $demand = new CategoryDemand(); diff --git a/Tests/Functional/Repository/EventRepositoryTest.php b/Tests/Functional/Repository/EventRepositoryTest.php index cc12d8bfe..56e60b9a7 100644 --- a/Tests/Functional/Repository/EventRepositoryTest.php +++ b/Tests/Functional/Repository/EventRepositoryTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Functional\Repository; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand; use DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand; use DERHANSEN\SfEventMgt\Domain\Repository\EventRepository; @@ -78,11 +80,11 @@ public static function findDemandedRecordsByStoragePageDataProvider(): array /** * Test if storagePage restriction in demand works - * @dataProvider findDemandedRecordsByStoragePageDataProvider - * @test * @param mixed $pid * @param int $expected */ + #[DataProvider('findDemandedRecordsByStoragePageDataProvider')] + #[Test] public function findDemandedRecordsByStoragePage(string $pid, int $expected): void { $demand = new EventDemand(); @@ -94,9 +96,8 @@ public function findDemandedRecordsByStoragePage(string $pid, int $expected): vo /** * Test if displayMode 'all' restriction in demand works - * - * @test */ + #[Test] public function findDemandedRecordsByDisplayModeAll(): void { $demand = new EventDemand(); @@ -109,9 +110,8 @@ public function findDemandedRecordsByDisplayModeAll(): void /** * Test if displayMode 'past' restriction in demand works. - * - * @test */ + #[Test] public function findDemandedRecordsByDisplayModePast(): void { $demand = new EventDemand(); @@ -125,9 +125,8 @@ public function findDemandedRecordsByDisplayModePast(): void /** * Test if displayMode 'past' restriction in demand works and ignores events with no enddate - * - * @test */ + #[Test] public function findDemandedRecordsByDisplayModePastForEventWithNoEnddate(): void { $demand = new EventDemand(); @@ -141,9 +140,8 @@ public function findDemandedRecordsByDisplayModePastForEventWithNoEnddate(): voi /** * Test if displayMode 'future' restriction in demand works - * - * @test */ + #[Test] public function findDemandedRecordsByDisplayModeFuture(): void { $demand = new EventDemand(); @@ -157,9 +155,8 @@ public function findDemandedRecordsByDisplayModeFuture(): void /** * Test if displayMode 'current_future' restriction in demand works - * - * @test */ + #[Test] public function findDemandedRecordsByDisplayModeCurrentFuture(): void { $demand = new EventDemand(); @@ -173,9 +170,8 @@ public function findDemandedRecordsByDisplayModeCurrentFuture(): void /** * Test if displayMode 'time_restriction' in demand works - * - * @test */ + #[Test] public function findDemandedRecordsByDisplayModeTimeRestriction(): void { $demand = new EventDemand(); @@ -276,13 +272,13 @@ public static function findDemandedRecordsByCategoryWithConjunctionDataProvider( /** * Test if category restiction with conjunction works * - * @dataProvider findDemandedRecordsByCategoryWithConjunctionDataProvider - * @test * @param mixed $category * @param mixed $conjunction * @param mixed $includeSub * @param mixed $expected */ + #[DataProvider('findDemandedRecordsByCategoryWithConjunctionDataProvider')] + #[Test] public function findDemandedRecordsByCategoryWithConjunction($category, $conjunction, $includeSub, $expected): void { $demand = new EventDemand(); @@ -314,11 +310,11 @@ public static function findDemandedRecordsByLocationDataProvider(): array /** * Test if location restriction works * - * @dataProvider findDemandedRecordsByLocationDataProvider - * @test * @param mixed $locationUid * @param mixed $expected */ + #[DataProvider('findDemandedRecordsByLocationDataProvider')] + #[Test] public function findDemandedRecordsByLocation($locationUid, $expected): void { $demand = new EventDemand(); @@ -345,10 +341,9 @@ public static function findDemandedRecordsByLocationCityDataProvider(): array /** * Test if location.city restriction works - * - * @dataProvider findDemandedRecordsByLocationCityDataProvider - * @test */ + #[DataProvider('findDemandedRecordsByLocationCityDataProvider')] + #[Test] public function findDemandedRecordsByLocationCity(string $locationCity, int $expected): void { $demand = new EventDemand(); @@ -374,10 +369,9 @@ public static function findDemandedRecordsByLocationCountryDataProvider(): array /** * Test if location.country restriction works - * - * @dataProvider findDemandedRecordsByLocationCountryDataProvider - * @test */ + #[DataProvider('findDemandedRecordsByLocationCountryDataProvider')] + #[Test] public function findDemandedRecordsByLocationCountry(string $locationCountry, int $expected): void { $demand = new EventDemand(); @@ -389,9 +383,8 @@ public function findDemandedRecordsByLocationCountry(string $locationCountry, in /** * Test if startDate restriction in demand works - * - * @test */ + #[Test] public function findSearchDemandedRecordsByStartDate(): void { $demand = new EventDemand(); @@ -408,9 +401,8 @@ public function findSearchDemandedRecordsByStartDate(): void /** * Test if endDate restriction in demand works - * - * @test */ + #[Test] public function findSearchDemandedRecordsByEndDate(): void { $demand = new EventDemand(); @@ -427,9 +419,8 @@ public function findSearchDemandedRecordsByEndDate(): void /** * Test if title restriction in demand works - * - * @test */ + #[Test] public function findSearchDemandedRecordsByFieldTitle(): void { $demand = new EventDemand(); @@ -466,11 +457,11 @@ public static function findDemandedRecordsByTopEventDataProvider(): array /** * Test if top event restriction in demand works * - * @dataProvider findDemandedRecordsByTopEventDataProvider - * @test * @param mixed $topEventRestriction * @param mixed $expected */ + #[DataProvider('findDemandedRecordsByTopEventDataProvider')] + #[Test] public function findDemandedRecordsByTopEvent($topEventRestriction, $expected): void { $demand = new EventDemand(); @@ -526,12 +517,12 @@ public static function findDemandedRecordsByOrderingDataProvider(): array /** * Test if ordering for findDemanded works * - * @dataProvider findDemandedRecordsByOrderingDataProvider - * @test * @param mixed $orderField * @param mixed $orderDirection * @param mixed $expected */ + #[DataProvider('findDemandedRecordsByOrderingDataProvider')] + #[Test] public function findDemandedRecordsByOrdering($orderField, $orderDirection, $expected): void { $demand = new EventDemand(); @@ -547,9 +538,8 @@ public function findDemandedRecordsByOrdering($orderField, $orderDirection, $exp /** * Test if ordering for findDemanded works but ignores unknown order by fields - * - * @test */ + #[Test] public function findDemandedRecordsByOrderingIgnoresUnknownOrderField(): void { $demand = new EventDemand(); @@ -565,9 +555,8 @@ public function findDemandedRecordsByOrderingIgnoresUnknownOrderField(): void /** * Test if limit restriction works - * - * @test */ + #[Test] public function findDemandedRecordsSetsLimit(): void { $demand = new EventDemand(); @@ -582,9 +571,8 @@ public function findDemandedRecordsSetsLimit(): void /** * Test if year restriction works - * - * @test */ + #[Test] public function findDemandedRecordsByYear(): void { $demand = new EventDemand(); @@ -599,9 +587,8 @@ public function findDemandedRecordsByYear(): void /** * Test if month restriction works - * - * @test */ + #[Test] public function findDemandedRecordsByMonth(): void { $demand = new EventDemand(); @@ -617,9 +604,8 @@ public function findDemandedRecordsByMonth(): void /** * Test if month restriction works, when start/enddate oi event span more than one month - * - * @test */ + #[Test] public function findDemandedRecordsByMonthWithStartdateInGivenMonth(): void { $demand = new EventDemand(); @@ -635,9 +621,8 @@ public function findDemandedRecordsByMonthWithStartdateInGivenMonth(): void /** * Test if month restriction works, when start/enddate oi event span more than one month - * - * @test */ + #[Test] public function findDemandedRecordsByMonthWithEnddateInGivenMonth(): void { $demand = new EventDemand(); @@ -653,9 +638,8 @@ public function findDemandedRecordsByMonthWithEnddateInGivenMonth(): void /** * Test if day restriction works - * - * @test */ + #[Test] public function findDemandedRecordsByDay(): void { $demand = new EventDemand(); @@ -673,9 +657,8 @@ public function findDemandedRecordsByDay(): void /** * Test if day restriction works, when event spans multiple days and restriction is limited to a * day, which is between the event start- and enddate - * - * @test */ + #[Test] public function findDemandedRecordsByDayForEventSpanningDateRange(): void { $demand = new EventDemand(); @@ -711,11 +694,11 @@ public static function findDemandedRecordsBySpeakerDataProvider(): array /** * Test if speaker restriction works * - * @dataProvider findDemandedRecordsBySpeakerDataProvider - * @test * @param mixed $speakerUid * @param mixed $expected */ + #[DataProvider('findDemandedRecordsBySpeakerDataProvider')] + #[Test] public function findDemandedRecordsBySpeaker($speakerUid, $expected): void { $demand = new EventDemand(); @@ -728,9 +711,8 @@ public function findDemandedRecordsBySpeaker($speakerUid, $expected): void /** * Test if startDate and endDate restriction in combination work - * - * @test */ + #[Test] public function findSearchDemandedRecordsByStartAndEndDate(): void { $demand = new EventDemand(); @@ -763,11 +745,11 @@ public static function findDemandedRespectsIgnoreEnableFieldsDataProvider(): arr /** * Test if ignoreEnableFields setting is respected * - * @dataProvider findDemandedRespectsIgnoreEnableFieldsDataProvider - * @test * @param bool $ignoreEnableFields * @param bool $expected */ + #[DataProvider('findDemandedRespectsIgnoreEnableFieldsDataProvider')] + #[Test] public function findDemandedRespectsIgnoreEnableFields($ignoreEnableFields, $expected): void { $demand = new EventDemand(); diff --git a/Tests/Functional/Repository/LocationRepositoryTest.php b/Tests/Functional/Repository/LocationRepositoryTest.php index ad3daa080..cf771f4f0 100644 --- a/Tests/Functional/Repository/LocationRepositoryTest.php +++ b/Tests/Functional/Repository/LocationRepositoryTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Functional\Repository; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Repository\LocationRepository; use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder; use TYPO3\CMS\Core\Http\ServerRequest; @@ -36,9 +37,7 @@ public function setUp(): void $GLOBALS['TYPO3_REQUEST'] = $request; } - /** - * @test - */ + #[Test] public function startingPageIsIgnored(): void { $locations = $this->locationRepository->findAll(); diff --git a/Tests/Functional/Repository/OrganisatorRepositoryTest.php b/Tests/Functional/Repository/OrganisatorRepositoryTest.php index bca07d0b3..fce47da67 100644 --- a/Tests/Functional/Repository/OrganisatorRepositoryTest.php +++ b/Tests/Functional/Repository/OrganisatorRepositoryTest.php @@ -9,6 +9,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Functional\Repository; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Repository\OrganisatorRepository; use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder; use TYPO3\CMS\Core\Http\ServerRequest; @@ -31,9 +32,7 @@ public function setUp(): void $GLOBALS['TYPO3_REQUEST'] = $request; } - /** - * @test - */ + #[Test] public function startingPageIsIgnored(): void { $locations = $this->organisatorRepository->findAll(); diff --git a/Tests/Functional/Repository/RegistrationRepositoryTest.php b/Tests/Functional/Repository/RegistrationRepositoryTest.php index b905863e4..313f8a1ac 100644 --- a/Tests/Functional/Repository/RegistrationRepositoryTest.php +++ b/Tests/Functional/Repository/RegistrationRepositoryTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Functional\Repository; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; use DERHANSEN\SfEventMgt\Domain\Model\Dto\CustomNotification; use DERHANSEN\SfEventMgt\Domain\Model\Dto\UserRegistrationDemand; use DERHANSEN\SfEventMgt\Domain\Model\Event; @@ -46,9 +48,8 @@ public function setUp(): void /** * Test for match on Event - * - * @test */ + #[Test] public function findNotificationRegistrationsForEventUid2(): void { $event = $this->getMockBuilder(Event::class)->getMock(); @@ -84,10 +85,8 @@ public static function confirmedAndUnconfirmedDataProvider(): array ]; } - /** - * @dataProvider confirmedAndUnconfirmedDataProvider - * @test - */ + #[DataProvider('confirmedAndUnconfirmedDataProvider')] + #[Test] public function findNotificationRegistrationsReturnsConfirmedAndUnconfirmed($recipientSetting, $expected): void { $event = $this->getMockBuilder(Event::class)->getMock(); @@ -148,11 +147,11 @@ public static function findNotificationRegistrationsDataProvider(): array /** * Test for match on Event * - * @dataProvider findNotificationRegistrationsDataProvider - * @test * @param mixed $constraints * @param mixed $expected */ + #[DataProvider('findNotificationRegistrationsDataProvider')] + #[Test] public function findNotificationRegistrationsForEventUid1WithConstraints($constraints, $expected): void { $event = $this->getMockBuilder(Event::class)->getMock(); @@ -170,9 +169,8 @@ public function findNotificationRegistrationsForEventUid1WithConstraints($constr /** * Test for match on Event with unknown condition - * - * @test */ + #[Test] public function findNotificationRegistrationsForEventWithConstraintsButWrongCondition(): void { $this->expectException(InvalidArgumentException::class); @@ -184,9 +182,8 @@ public function findNotificationRegistrationsForEventWithConstraintsButWrongCond /** * Test if ignoreNotifications is respected - * - * @test */ + #[Test] public function findNotificationRegistrationsRespectsIgnoreNotificationsForEventUid3(): void { $event = $this->getMockBuilder(Event::class)->getMock(); @@ -202,9 +199,8 @@ public function findNotificationRegistrationsRespectsIgnoreNotificationsForEvent /** * Test if findRegistrationsByUserRegistrationDemand returns an empty array if no user given - * - * @test */ + #[Test] public function findRegistrationsByUserRegistrationDemandReturnsEmptyArrayIfNoUser(): void { $demand = new UserRegistrationDemand(); @@ -215,9 +211,8 @@ public function findRegistrationsByUserRegistrationDemandReturnsEmptyArrayIfNoUs /** * Test if findRegistrationsByUserRegistrationDemand respects storagePage constraint - * - * @test */ + #[Test] public function findRegistrationsByUserRegistrationDemandRespectsStoragePage(): void { $feUserRepository = $this->getContainer()->get(FrontendUserRepository::class); @@ -232,9 +227,8 @@ public function findRegistrationsByUserRegistrationDemandRespectsStoragePage(): /** * Test if findRegistrationsByUserRegistrationDemand respects displayMode "future" constraint - * - * @test */ + #[Test] public function findRegistrationsByUserRegistrationDemandRespectsDisplaymodeFuture(): void { $feUserRepository = $this->getContainer()->get(FrontendUserRepository::class); @@ -250,9 +244,8 @@ public function findRegistrationsByUserRegistrationDemandRespectsDisplaymodeFutu /** * Test if findRegistrationsByUserRegistrationDemand respects displayMode "future" constraint - * - * @test */ + #[Test] public function findRegistrationsByUserRegistrationDemandRespectsDisplaymodeCurrentFuture(): void { $feUserRepository = $this->getContainer()->get(FrontendUserRepository::class); @@ -268,9 +261,8 @@ public function findRegistrationsByUserRegistrationDemandRespectsDisplaymodeCurr /** * Test if findRegistrationsByUserRegistrationDemand respects user constraint - * - * @test */ + #[Test] public function findRegistrationsByUserRegistrationDemandRespectsUser(): void { $feUserRepository = $this->getContainer()->get(FrontendUserRepository::class); @@ -285,9 +277,8 @@ public function findRegistrationsByUserRegistrationDemandRespectsUser(): void /** * Test if findRegistrationsByUserRegistrationDemand respects order constraint - * - * @test */ + #[Test] public function findRegistrationsByUserRegistrationDemandRespectsOrder(): void { $feUserRepository = $this->getContainer()->get(FrontendUserRepository::class); @@ -304,9 +295,8 @@ public function findRegistrationsByUserRegistrationDemandRespectsOrder(): void /** * Test if findRegistrationsByUserRegistrationDemand respects order direction constraint - * - * @test */ + #[Test] public function findRegistrationsByUserRegistrationDemandRespectsOrderDirection(): void { $feUserRepository = $this->getContainer()->get(FrontendUserRepository::class); @@ -321,9 +311,7 @@ public function findRegistrationsByUserRegistrationDemandRespectsOrderDirection( self::assertEquals(32, $registrations->getFirst()->getUid()); } - /** - * @test - */ + #[Test] public function findWaitlistMoveUpRegistrationsReturnsExpectedAmountOfRegistrationsAndRespectsOrder(): void { $event = $this->getMockBuilder(Event::class)->getMock(); diff --git a/Tests/Functional/Service/CalendarServiceTest.php b/Tests/Functional/Service/CalendarServiceTest.php index 2f030179a..0a6c205ec 100644 --- a/Tests/Functional/Service/CalendarServiceTest.php +++ b/Tests/Functional/Service/CalendarServiceTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Functional\Service; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand; use DERHANSEN\SfEventMgt\Domain\Repository\EventRepository; use DERHANSEN\SfEventMgt\Service\CalendarService; @@ -32,9 +33,8 @@ public function setUp(): void /** * Test, if events for the 27.10.2024 (date with timeshift) will be returned in the array - * - * @test */ + #[Test] public function getCalendarArrayReturnsArrayWithExpectedEventOnADayWithTimeshiftOctober(): void { $demand = new EventDemand(); @@ -48,9 +48,8 @@ public function getCalendarArrayReturnsArrayWithExpectedEventOnADayWithTimeshift /** * Test, if events for the 31.03.2024 (date with timeshift) will be returned in the array - * - * @test */ + #[Test] public function getCalendarArrayReturnsArrayWithExpectedEventOnADayWithTimeshiftMarch(): void { $demand = new EventDemand(); diff --git a/Tests/Functional/Service/FluidStandaloneServiceTest.php b/Tests/Functional/Service/FluidStandaloneServiceTest.php index 57752a479..6a09e3f81 100644 --- a/Tests/Functional/Service/FluidStandaloneServiceTest.php +++ b/Tests/Functional/Service/FluidStandaloneServiceTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Functional\Service; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Registration; use DERHANSEN\SfEventMgt\Service\FluidStandaloneService; use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder; @@ -27,9 +28,7 @@ public function setUp(): void parent::setUp(); } - /** - * @test - */ + #[Test] public function parseStringFluidReturnsExpectedResultForSimpleVariable(): void { $subject = new FluidStandaloneService(); @@ -40,9 +39,7 @@ public function parseStringFluidReturnsExpectedResultForSimpleVariable(): void self::assertEquals($expected, $subject->parseStringFluid($fluidString, ['variable' => 'variable'])); } - /** - * @test - */ + #[Test] public function parseStringFluidReturnsExpectedResultForExtbaseDomainObjectVariable(): void { $subject = new FluidStandaloneService(); diff --git a/Tests/Functional/Service/MaintenanceServiceTest.php b/Tests/Functional/Service/MaintenanceServiceTest.php index 3cee7673c..4f89b59ce 100644 --- a/Tests/Functional/Service/MaintenanceServiceTest.php +++ b/Tests/Functional/Service/MaintenanceServiceTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Functional\Service; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Service\MaintenanceService; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -26,9 +27,7 @@ public function setUp(): void $this->importCSVDataSet(__DIR__ . '/../Fixtures/handle_expired_registrations.csv'); } - /** - * @test - */ + #[Test] public function handleExpiredRegistrationsHidesExpectedRegistrations() { $subject = GeneralUtility::makeInstance(MaintenanceService::class); @@ -44,9 +43,7 @@ public function handleExpiredRegistrationsHidesExpectedRegistrations() self::assertEquals(0, $registration3['hidden'], 'Registration 3'); } - /** - * @test - */ + #[Test] public function handleExpiredRegistrationsDeletesExpectedRegistrations() { $subject = GeneralUtility::makeInstance(MaintenanceService::class); diff --git a/Tests/Functional/Validation/Validator/RegistrationFieldValidatorTest.php b/Tests/Functional/Validation/Validator/RegistrationFieldValidatorTest.php index b9d966c57..a1d2a1d45 100644 --- a/Tests/Functional/Validation/Validator/RegistrationFieldValidatorTest.php +++ b/Tests/Functional/Validation/Validator/RegistrationFieldValidatorTest.php @@ -11,6 +11,10 @@ namespace DERHANSEN\SfEventMgt\Tests\Functional\Validation\Validator; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; +use DERHANSEN\SfEventMgt\Domain\Model\Registration\Field; +use DERHANSEN\SfEventMgt\Domain\Model\Registration\FieldValue; use DERHANSEN\SfEventMgt\Domain\Model\Event; use DERHANSEN\SfEventMgt\Domain\Model\Registration; use DERHANSEN\SfEventMgt\Utility\FieldType; @@ -32,9 +36,7 @@ protected function setUp(): void $GLOBALS['TYPO3_REQUEST'] = $request; } - /** - * @test - */ + #[Test] public function validatorHasNoErrorsWhenRegistrationHasNoFields(): void { $registration = new Registration(); @@ -73,17 +75,15 @@ public static function validatorDataProvider(): array ]; } - /** - * @test - * @dataProvider validatorDataProvider - */ + #[DataProvider('validatorDataProvider')] + #[Test] public function validatorReturnsExpectedResultForRegistrationField( bool $required, string $fieldType, string $fieldValue, bool $expectedResult ): void { - $registrationField = new Registration\Field(); + $registrationField = new Field(); $registrationField->setText($fieldType); $registrationField->setRequired($required); @@ -95,7 +95,7 @@ public function validatorReturnsExpectedResultForRegistrationField( $registration = new Registration(); $registration->setEvent($event); - $registrationFieldValue = new Registration\FieldValue(); + $registrationFieldValue = new FieldValue(); $registrationFieldValue->setField($registrationField); $registrationFieldValue->setValue($fieldValue); diff --git a/Tests/Functional/Validation/Validator/RegistrationValidatorTest.php b/Tests/Functional/Validation/Validator/RegistrationValidatorTest.php index 210ba3a35..7aa89bffb 100644 --- a/Tests/Functional/Validation/Validator/RegistrationValidatorTest.php +++ b/Tests/Functional/Validation/Validator/RegistrationValidatorTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Functional\Validation\Validator; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Registration; use DERHANSEN\SfEventMgt\Validation\Validator\RegistrationValidator; use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder; @@ -30,9 +31,7 @@ protected function setUp(): void $GLOBALS['TYPO3_REQUEST'] = $request; } - /** - * @test - */ + #[Test] public function registrationInvalidWhenDefaultFieldsNotSet(): void { $registration = new Registration(); @@ -47,9 +46,7 @@ public function registrationInvalidWhenDefaultFieldsNotSet(): void self::assertTrue(isset($errors['email'])); } - /** - * @test - */ + #[Test] public function registrationValidWhenDefaultFieldsSet(): void { $registration = new Registration(); @@ -63,9 +60,7 @@ public function registrationValidWhenDefaultFieldsSet(): void self::assertFalse($result->hasErrors()); } - /** - * @test - */ + #[Test] public function registrationInvalidWhenCustomRequiredFieldsNotSet(): void { $configuration = [ @@ -96,9 +91,7 @@ public function registrationInvalidWhenCustomRequiredFieldsNotSet(): void self::assertTrue(isset($errors['accepttc'])); } - /** - * @test - */ + #[Test] public function registrationValidWhenCustomRequiredFieldsDoesNotExist(): void { $configuration = [ diff --git a/Tests/Functional/ViewHelpers/Category/CountViewHelperTest.php b/Tests/Functional/ViewHelpers/Category/CountViewHelperTest.php index 4a7bfd9fc..07a362348 100644 --- a/Tests/Functional/ViewHelpers/Category/CountViewHelperTest.php +++ b/Tests/Functional/ViewHelpers/Category/CountViewHelperTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\ViewHelpers\Category; +use PHPUnit\Framework\Attributes\Test; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Fluid\View\StandaloneView; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -33,9 +34,7 @@ public function setUp(): void ->setTemplateSource(''); } - /** - * @test - */ + #[Test] public function viewHelperReturnsExpectedResult(): void { $result = $this->view->assign('categoryUid', 5)->render(); diff --git a/Tests/Functional/ViewHelpers/MetaTagViewHelperTest.php b/Tests/Functional/ViewHelpers/MetaTagViewHelperTest.php index 601ae325c..fac21bd59 100644 --- a/Tests/Functional/ViewHelpers/MetaTagViewHelperTest.php +++ b/Tests/Functional/ViewHelpers/MetaTagViewHelperTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\ViewHelpers; +use PHPUnit\Framework\Attributes\Test; use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Fluid\View\StandaloneView; @@ -31,9 +32,7 @@ public function setUp(): void $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); } - /** - * @test - */ + #[Test] public function metaTagForNameIsSetByViewHelper(): void { $this->view->getRenderingContext()->getViewHelperResolver() @@ -46,9 +45,7 @@ public function metaTagForNameIsSetByViewHelper(): void self::assertEquals('keyword1, keyword2', $metaTag['content']); } - /** - * @test - */ + #[Test] public function metaTagForPropertyIsSetByViewHelper(): void { $this->view->getRenderingContext()->getViewHelperResolver() diff --git a/Tests/Functional/ViewHelpers/TitleViewHelperTest.php b/Tests/Functional/ViewHelpers/TitleViewHelperTest.php index 1e34190b3..51adf4950 100644 --- a/Tests/Functional/ViewHelpers/TitleViewHelperTest.php +++ b/Tests/Functional/ViewHelpers/TitleViewHelperTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\ViewHelpers; +use PHPUnit\Framework\Attributes\Test; use TYPO3\CMS\Core\PageTitle\PageTitleProviderManager; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Fluid\View\StandaloneView; @@ -43,9 +44,7 @@ public function setUp(): void $GLOBALS['TSFE'] = $tsfe; } - /** - * @test - */ + #[Test] public function viewHelperReturnsExpectedResult(): void { self::assertEmpty($this->view->assign('title', 'Test')->render()); diff --git a/Tests/Unit/Controller/AdministrationControllerTest.php b/Tests/Unit/Controller/AdministrationControllerTest.php index e809fb080..9ca247015 100644 --- a/Tests/Unit/Controller/AdministrationControllerTest.php +++ b/Tests/Unit/Controller/AdministrationControllerTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Controller; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Controller\AdministrationController; use DERHANSEN\SfEventMgt\Domain\Model\Dto\CustomNotification; use DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand; @@ -50,9 +51,7 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function initializeActionAssignsPid(): void { $this->subject->_set('pid', 1); @@ -61,9 +60,7 @@ public function initializeActionAssignsPid(): void self::assertSame(0, $this->subject->_get('pid')); } - /** - * @test - */ + #[Test] public function listActionDoesNotFetchEventsForStoragePidZero(): void { $this->subject->_set('settings', ['dummy' => 'settings']); @@ -105,9 +102,7 @@ public function listActionDoesNotFetchEventsForStoragePidZero(): void $this->subject->listAction(); } - /** - * @test - */ + #[Test] public function listActionDoesNotFetchEventsForStoragePidZeroAndDemand(): void { $this->subject->_set('settings', ['dummy' => 'settings']); @@ -151,9 +146,7 @@ public function listActionDoesNotFetchEventsForStoragePidZeroAndDemand(): void $this->subject->listAction($searchDemand); } - /** - * @test - */ + #[Test] public function listActionFetchesAllEventsForGivenStoragePidAndPassesExpectedVariablesToTemplateView(): void { $this->subject->_set('settings', ['dummy' => 'settings']); @@ -205,9 +198,7 @@ public function listActionFetchesAllEventsForGivenStoragePidAndPassesExpectedVar $this->subject->listAction($searchDemand); } - /** - * @test - */ + #[Test] public function listActionUsesOverwriteDemandArrayAndPassesExpectedVariablesToTemplateView(): void { $this->subject->_set('settings', ['dummy' => 'settings']); @@ -256,9 +247,7 @@ public function listActionUsesOverwriteDemandArrayAndPassesExpectedVariablesToTe $this->subject->listAction($searchDemand, ['orderDirection' => 'desc']); } - /** - * @test - */ + #[Test] public function initializeListActionSetsDefaultDateFormatIfEmpty(): void { $settings = [ @@ -271,9 +260,7 @@ public function initializeListActionSetsDefaultDateFormatIfEmpty(): void self::assertEquals('H:i d-m-Y', $this->subject->_get('settings')['search']['dateFormat']); } - /** - * @test - */ + #[Test] public function handleExpiredRegistrationsCallsServiceAndRedirectsToListView(): void { $mockMaintenanceService = $this->getMockBuilder(MaintenanceService::class) @@ -285,9 +272,7 @@ public function handleExpiredRegistrationsCallsServiceAndRedirectsToListView(): $this->subject->handleExpiredRegistrationsAction(); } - /** - * @test - */ + #[Test] public function indexNotifyActionPassesExpectedVariablesToTemplateView(): void { $this->subject->_set('settings', ['dummy' => 'settings']); @@ -333,9 +318,7 @@ public function indexNotifyActionPassesExpectedVariablesToTemplateView(): void $this->subject->indexNotifyAction($event); } - /** - * @test - */ + #[Test] public function notifyActionSendsNotificationsLogsAndRedirects(): void { $customNotifications = ['key' => 'value']; @@ -364,9 +347,7 @@ public function notifyActionSendsNotificationsLogsAndRedirects(): void $this->subject->notifyAction($event, $customNotification); } - /** - * @test - */ + #[Test] public function checkEventAccessReturnsFalseIfNoEventAccess(): void { $event = new Event(); diff --git a/Tests/Unit/Controller/EventControllerTest.php b/Tests/Unit/Controller/EventControllerTest.php index a387adc90..163ef67fd 100644 --- a/Tests/Unit/Controller/EventControllerTest.php +++ b/Tests/Unit/Controller/EventControllerTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Controller; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; use DateInterval; use DateTime; use DERHANSEN\SfEventMgt\Controller\EventController; @@ -102,9 +104,8 @@ protected function tearDown(): void /** * Test if overwriteDemand ignores properties in $ignoredSettingsForOverwriteDemand - * - * @test */ + #[Test] public function overwriteDemandObjectIgnoresIgnoredProperties() { $demand = new EventDemand(); @@ -123,9 +124,8 @@ public function overwriteDemandObjectIgnoresIgnoredProperties() /** * Test if overwriteDemand sets a property in the given demand - * - * @test */ + #[Test] public function overwriteDemandObjectSetsCategoryProperty() { $demand = new EventDemand(); @@ -142,9 +142,7 @@ public function overwriteDemandObjectSetsCategoryProperty() self::assertSame('1', $resultDemand->getCategory()); } - /** - * @test - */ + #[Test] public function initializeSaveRegistrationActionSetsDateFormat() { $settings = [ @@ -188,9 +186,7 @@ public function initializeSaveRegistrationActionSetsDateFormat() $this->subject->initializeSaveRegistrationAction(); } - /** - * @test - */ + #[Test] public function listActionFetchesAllEventsFromRepositoryAndAssignsThemToView() { $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock(); @@ -279,9 +275,7 @@ public function listActionFetchesAllEventsFromRepositoryAndAssignsThemToView() $this->subject->listAction(); } - /** - * @test - */ + #[Test] public function listActionOverridesDemandAndFetchesAllEventsFromRepositoryAndAssignsThemToView() { $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock(); @@ -373,9 +367,7 @@ public function listActionOverridesDemandAndFetchesAllEventsFromRepositoryAndAss $this->subject->listAction($overrideDemand); } - /** - * @test - */ + #[Test] public function listActionDoesNotOverrideDemandIfDisabled() { $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock(); @@ -467,9 +459,7 @@ public function listActionDoesNotOverrideDemandIfDisabled() $this->subject->listAction($overrideDemand); } - /** - * @test - */ + #[Test] public function detailActionAssignsEventToView() { $event = new Event(); @@ -493,9 +483,7 @@ public function detailActionAssignsEventToView() $this->subject->detailAction($event); } - /** - * @test - */ + #[Test] public function registrationActionAssignsEventToView() { $event = new Event(); @@ -520,9 +508,7 @@ public function registrationActionAssignsEventToView() $this->subject->registrationAction($event); } - /** - * @test - */ + #[Test] public function saveRegistrationActionRedirectsWithMessageIfRegistrationDisabled() { $hashService = $this->getMockBuilder(HashService::class)->getMock(); @@ -548,9 +534,7 @@ public function saveRegistrationActionRedirectsWithMessageIfRegistrationDisabled $this->subject->saveRegistrationAction($registration, $event); } - /** - * @test - */ + #[Test] public function saveRegistrationActionRedirectsWithMessageIfRegistrationDeadlineExpired() { $hashService = $this->getMockBuilder(HashService::class)->getMock(); @@ -579,9 +563,7 @@ public function saveRegistrationActionRedirectsWithMessageIfRegistrationDeadline $this->subject->saveRegistrationAction($registration, $event); } - /** - * @test - */ + #[Test] public function saveRegistrationActionRedirectsWithMessageIfEventExpired() { $hashService = $this->getMockBuilder(HashService::class)->getMock(); @@ -610,9 +592,7 @@ public function saveRegistrationActionRedirectsWithMessageIfEventExpired() $this->subject->saveRegistrationAction($registration, $event); } - /** - * @test - */ + #[Test] public function saveRegistrationRedirectsWithMessageIfMaxParticipantsReached() { $hashService = $this->getMockBuilder(HashService::class)->getMock(); @@ -646,9 +626,7 @@ public function saveRegistrationRedirectsWithMessageIfMaxParticipantsReached() $this->subject->saveRegistrationAction($registration, $event); } - /** - * @test - */ + #[Test] public function saveRegistrationRedirectsWithMessageIfAmountOfRegistrationsGreaterThanRemainingPlaces() { $hashService = $this->getMockBuilder(HashService::class)->getMock(); @@ -685,9 +663,7 @@ public function saveRegistrationRedirectsWithMessageIfAmountOfRegistrationsGreat $this->subject->saveRegistrationAction($registration, $event); } - /** - * @test - */ + #[Test] public function saveRegistrationRedirectsWithMessageIfAmountOfRegistrationsExceedsMaxAmountOfRegistrations() { $hashService = $this->getMockBuilder(HashService::class)->getMock(); @@ -725,9 +701,7 @@ public function saveRegistrationRedirectsWithMessageIfAmountOfRegistrationsExcee $this->subject->saveRegistrationAction($registration, $event); } - /** - * @test - */ + #[Test] public function saveRegistrationRedirectsWithMessageIfUniqueEmailCheckEnabledAndEmailAlreadyRegistered() { $hashService = $this->getMockBuilder(HashService::class)->getMock(); @@ -779,9 +753,8 @@ public function saveRegistrationRedirectsWithMessageIfUniqueEmailCheckEnabledAnd /** * Checks, if a saveRegistration action with no autoConfirmation saves the * registration if maxParticipants is reached and waitlist is enabled - * - * @test */ + #[Test] public function saveRegistrationActionWithoutAutoConfirmationAndWaitlistRedirectsWithMessageIfRegistrationSuccessful() { $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock(); @@ -848,9 +821,8 @@ public function saveRegistrationActionWithoutAutoConfirmationAndWaitlistRedirect /** * Checks, if a saveRegistration action with no autoConfirmation saves the * registration and redirects to the saveRegistrationResult action. - * - * @test */ + #[Test] public function saveRegistrationActionWithoutAutoConfirmationRedirectsWithMessageIfRegistrationSuccessful() { $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock(); @@ -916,9 +888,8 @@ public function saveRegistrationActionWithoutAutoConfirmationRedirectsWithMessag /** * Checks, if a saveRegistration action with autoConfirmation (settings) saves the * registration and redirects to the confirmationRegistration action. - * - * @test */ + #[Test] public function saveRegistrationWithSettingAutoConfirmationActionRedirectsToConfirmationWithMessage() { $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock(); @@ -989,9 +960,8 @@ public function saveRegistrationWithSettingAutoConfirmationActionRedirectsToConf /** * Checks, if a saveRegistration action with autoConfirmation (in event) saves the * registration and redirects to the confirmationRegistration action. - * - * @test */ + #[Test] public function saveRegistrationWithEventAutoConfirmationActionRedirectsToConfirmationWithMessage() { $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock(); @@ -1058,9 +1028,8 @@ public function saveRegistrationWithEventAutoConfirmationActionRedirectsToConfir /** * Checks, if a saveRegistration action creates multiple registrations * if getAmountOfRegistrations > 1 - * - * @test */ + #[Test] public function saveRegistrationCreatesMultipleRegistrationIfAmountOfRegistrationsGreaterThanOne() { $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock(); @@ -1129,9 +1098,7 @@ public function saveRegistrationCreatesMultipleRegistrationIfAmountOfRegistratio $this->subject->saveRegistrationAction($registration, $event); } - /** - * @test - */ + #[Test] public function saveRegistrationResultActionShowsExpectedMessageIfWrongHmacGiven() { $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock(); @@ -1254,10 +1221,9 @@ public static function invalidEmailsDataProvider(): array /** * Test if expected messsage is returned for saveRegistrationResult - * - * @dataProvider invalidEmailsDataProvider - * @test */ + #[DataProvider('invalidEmailsDataProvider')] + #[Test] public function saveRegistrationResultActionShowsExpectedMessage($result, $eventUid, $reguid, $hmac, $message, $title, $failed) { $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock(); @@ -1300,9 +1266,8 @@ public function saveRegistrationResultActionShowsExpectedMessage($result, $event /** * Test if expected message is shown if checkConfirmRegistration fails - * - * @test */ + #[Test] public function confirmRegistrationActionShowsExpectedMessageIfCheckConfirmRegistrationFailed() { $variables = [ @@ -1346,9 +1311,8 @@ public function confirmRegistrationActionShowsExpectedMessageIfCheckConfirmRegis /** * Test if expected message is shown if checkConfirmRegistration succeeds. * Also checks, if messages are sent and if registration gets confirmed. - * - * @test */ + #[Test] public function confirmRegistrationActionShowsMessageIfCheckCancelRegistrationSucceeds() { $event = new Event(); @@ -1414,9 +1378,8 @@ public function confirmRegistrationActionShowsMessageIfCheckCancelRegistrationSu /** * Test if expected message is shown if checkConfirmRegistration succeeds for waitist registrations * Also checks, if messages are sent and if registration gets confirmed. - * - * @test */ + #[Test] public function confirmRegistrationWaitlistActionShowsMessageIfCheckCancelRegistrationSucceeds() { $event = new Event(); @@ -1477,9 +1440,8 @@ public function confirmRegistrationWaitlistActionShowsMessageIfCheckCancelRegist /** * Test if expected message is shown if checkCancelRegistration fails - * - * @test */ + #[Test] public function cancelRegistrationActionShowsMessageIfCheckCancelRegistrationFailed() { $variables = [ @@ -1521,9 +1483,8 @@ public function cancelRegistrationActionShowsMessageIfCheckCancelRegistrationFai /** * Test if expected message is shown if checkCancelRegistration succeeds. * Also checks, if messages are sent and if registration gets removed. - * - * @test */ + #[Test] public function cancelRegistrationActionShowsMessageIfCheckCancelRegistrationSucceeds() { $mockEvent = $this->getMockBuilder(Event::class)->getMock(); @@ -1651,9 +1612,7 @@ protected function getInitializeSearchActionArgumentMock($settingsSearchDateForm return $mockArguments; } - /** - * @test - */ + #[Test] public function initializeSearchActionSetsDateFormat() { $settings = [ @@ -1667,9 +1626,7 @@ public function initializeSearchActionSetsDateFormat() $this->subject->initializeSearchAction(); } - /** - * @test - */ + #[Test] public function searchActionFetchesAllEventsFromRepositoryAndAssignsThemToViewForNoSearchDemand() { $allEvents = $this->createMock(QueryResult::class); @@ -1746,9 +1703,7 @@ public function searchActionFetchesAllEventsFromRepositoryAndAssignsThemToViewFo $this->subject->searchAction(); } - /** - * @test - */ + #[Test] public function searchActionFetchesAllEventsFromRepositoryAndAssignsThemToViewWithSearchDemand() { $searchDemand = $this->getMockBuilder(SearchDemand::class)->getMock(); @@ -1828,9 +1783,7 @@ public function searchActionFetchesAllEventsFromRepositoryAndAssignsThemToViewWi $this->subject->searchAction($searchDemand); } - /** - * @test - */ + #[Test] public function searchActionSetsSearchDemandFieldsIfSearchDemandGiven() { $searchDemand = $this->getMockBuilder(SearchDemand::class)->getMock(); @@ -1893,9 +1846,7 @@ public function searchActionSetsSearchDemandFieldsIfSearchDemandGiven() $this->subject->searchAction($searchDemand); } - /** - * @test - */ + #[Test] public function searchActionSetsAdjustsDateFieldsIfAdjustDateSettingSetAndDateFieldsGiven() { $mockStartDate = $this->getMockBuilder('\DateTime')->getMock(); @@ -1971,9 +1922,7 @@ public function searchActionSetsAdjustsDateFieldsIfAdjustDateSettingSetAndDateFi $this->subject->searchAction($searchDemand); } - /** - * @test - */ + #[Test] public function searchActionOverwritesDemandFieldsIfOverwriteDemandObjectGiven() { $searchDemand = $this->getMockBuilder(SearchDemand::class)->getMock(); @@ -2039,9 +1988,7 @@ public function searchActionOverwritesDemandFieldsIfOverwriteDemandObjectGiven() $this->subject->searchAction($searchDemand, $overrideDemand); } - /** - * @test - */ + #[Test] public function searchActionDoesNotOverridesDemandIfOverwriteDemandDisabled() { $searchDemand = $this->getMockBuilder(SearchDemand::class)->getMock(); @@ -2107,9 +2054,7 @@ public function searchActionDoesNotOverridesDemandIfOverwriteDemandDisabled() $this->subject->searchAction($searchDemand, $overrideDemand); } - /** - * @test - */ + #[Test] public function detailActionShowsEventIfEventGiven() { $mockEvent = $this->getMockBuilder(Event::class)->getMock(); @@ -2132,9 +2077,7 @@ public function detailActionShowsEventIfEventGiven() $this->subject->detailAction($mockEvent); } - /** - * @test - */ + #[Test] public function handleEventNotFoundIsSkippedWhenNoSetting(): void { $settings = [ @@ -2148,9 +2091,7 @@ public function handleEventNotFoundIsSkippedWhenNoSetting(): void $mock->_call('handleEventNotFoundError', $settings); } - /** - * @test - */ + #[Test] public function handleEventNotFoundShows404Page() { $settings = [ @@ -2171,9 +2112,7 @@ public function handleEventNotFoundShows404Page() $mock->_call('handleEventNotFoundError', $settings); } - /** - * @test - */ + #[Test] public function handleEventNotFoundRedirectsToListView() { $settings = [ @@ -2188,9 +2127,7 @@ public function handleEventNotFoundRedirectsToListView() $mock->_call('handleEventNotFoundError', $settings); } - /** - * @test - */ + #[Test] public function handleEventNotFoundRedirectsToPid1IfNoListPidDefinied() { $settings = [ @@ -2204,9 +2141,7 @@ public function handleEventNotFoundRedirectsToPid1IfNoListPidDefinied() $mock->_call('handleEventNotFoundError', $settings); } - /** - * @test - */ + #[Test] public function changeEventDemandToFullMonthDateRangeAppliesExpectedDatesAndUnsetsMonthAndYear() { $calendarDateRangeResult = [ @@ -2242,9 +2177,7 @@ public function changeEventDemandToFullMonthDateRangeAppliesExpectedDatesAndUnse self::assertSame('05.02.2017 23:59:59', $resultDemand->getSearchDemand()->getEndDate()->format('d.m.Y H:i:s')); } - /** - * @test - */ + #[Test] public function checkPidOfEventRecordWorks() { $mockedController = $this->getAccessibleMock(EventController::class, null); @@ -2276,9 +2209,7 @@ public function checkPidOfEventRecordWorks() self::assertNull($mockedController->_call('checkPidOfEventRecord', $event)); } - /** - * @test - */ + #[Test] public function evaluateSingleEventSettingIsWorking() { $mockedController = $this->getAccessibleMock(EventController::class, null); @@ -2301,9 +2232,7 @@ public function evaluateSingleEventSettingIsWorking() self::assertEquals($mockEvent, $mockedController->_call('evaluateSingleEventSetting', null)); } - /** - * @test - */ + #[Test] public function evaluateIsShortcutSettingIsWorking() { $mockedController = $this->getAccessibleMock(EventController::class, null); @@ -2333,9 +2262,7 @@ public function evaluateIsShortcutSettingIsWorking() self::assertEquals($mockEvent, $mockedController->_call('evaluateIsShortcutSetting', null)); } - /** - * @test - */ + #[Test] public function evaluateEventPreviewSettingReturnsNoEventIfNoEventPreview(): void { $mockedController = $this->getAccessibleMock(EventController::class, null); @@ -2346,9 +2273,7 @@ public function evaluateEventPreviewSettingReturnsNoEventIfNoEventPreview(): voi self::assertNull($mockedController->_call('evaluateEventPreviewSetting', null)); } - /** - * @test - */ + #[Test] public function evaluateEventPreviewSettingReturnsNoEventIfNoBackendUser(): void { $mockedController = $this->getAccessibleMock(EventController::class, null); @@ -2364,9 +2289,7 @@ public function evaluateEventPreviewSettingReturnsNoEventIfNoBackendUser(): void self::assertNull($mockedController->_call('evaluateEventPreviewSetting', null)); } - /** - * @test - */ + #[Test] public function evaluateEventPreviewSettingReturnsEventForValidBackendUserAndNoPreviewHiddenRecordsSetting(): void { $mockedController = $this->getAccessibleMock(EventController::class, null); @@ -2388,9 +2311,7 @@ public function evaluateEventPreviewSettingReturnsEventForValidBackendUserAndNoP self::assertNull($mockedController->_call('evaluateEventPreviewSetting', null)); } - /** - * @test - */ + #[Test] public function evaluateEventPreviewSettingReturnsEventForValidBackendUserAndPreviewHiddenRecordsSetting(): void { $mockedController = $this->getAccessibleMock(EventController::class, null); @@ -2412,9 +2333,7 @@ public function evaluateEventPreviewSettingReturnsEventForValidBackendUserAndPre self::assertNull($mockedController->_call('evaluateEventPreviewSetting', null)); } - /** - * @test - */ + #[Test] public function evaluateEventPreviewSettingIsWorking() { $mockedController = $this->getAccessibleMock(EventController::class, null); @@ -2483,10 +2402,8 @@ public static function isOverwriteDemandDataProvider(): array ]; } - /** - * @test - * @dataProvider isOverwriteDemandDataProvider - */ + #[DataProvider('isOverwriteDemandDataProvider')] + #[Test] public function isOverwriteDemandIsWorking(array $settings, array $overwriteDemand, bool $expected): void { $mockedController = $this->getAccessibleMock(EventController::class, null); diff --git a/Tests/Unit/Controller/PaymentControllerTest.php b/Tests/Unit/Controller/PaymentControllerTest.php index f457089f0..20fab0316 100644 --- a/Tests/Unit/Controller/PaymentControllerTest.php +++ b/Tests/Unit/Controller/PaymentControllerTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Controller; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Controller\PaymentController; use DERHANSEN\SfEventMgt\Domain\Model\Registration; use DERHANSEN\SfEventMgt\Event\ProcessPaymentCancelEvent; @@ -65,9 +66,8 @@ protected function tearDown(): void /** * Test if ProcessPaymentInitializeEvent is dispatched - * - * @test */ + #[Test] public function redirectActionCallsBeforeRedirectSignal() { $mockRegistration = $this->getMockBuilder(Registration::class)->getMock(); @@ -97,9 +97,8 @@ public function redirectActionCallsBeforeRedirectSignal() /** * Test if ProcessPaymentSuccessEvent is dispatched - * - * @test */ + #[Test] public function successActionCallsProcessSuccessSignal() { $mockRegistration = $this->getMockBuilder(Registration::class)->getMock(); @@ -133,9 +132,8 @@ public function successActionCallsProcessSuccessSignal() /** * Test if ProcessPaymentFailureEvent is dispatched - * - * @test */ + #[Test] public function failureActionCallsProcessFailureSignal() { $mockRegistration = $this->getMockBuilder(Registration::class)->getMock(); @@ -169,9 +167,8 @@ public function failureActionCallsProcessFailureSignal() /** * Test if ProcessPaymentCancelEvent is dispatched - * - * @test */ + #[Test] public function cancelActionCallsProcessCancelSignal() { $mockRegistration = $this->getMockBuilder(Registration::class)->getMock(); @@ -205,9 +202,8 @@ public function cancelActionCallsProcessCancelSignal() /** * Test if ProcessPaymentNotifyEvent is dispatched - * - * @test */ + #[Test] public function notifyActionCallsProcessNotifySignal() { $mockRegistration = $this->getMockBuilder(Registration::class)->getMock(); diff --git a/Tests/Unit/Controller/UserRegistrationControllerTest.php b/Tests/Unit/Controller/UserRegistrationControllerTest.php index e3993dccd..d5ca2e7cc 100644 --- a/Tests/Unit/Controller/UserRegistrationControllerTest.php +++ b/Tests/Unit/Controller/UserRegistrationControllerTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Controller; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Controller\UserRegistrationController; use DERHANSEN\SfEventMgt\Domain\Model\FrontendUser; use DERHANSEN\SfEventMgt\Domain\Model\Registration; @@ -49,9 +50,8 @@ protected function tearDown(): void /** * Test if listAction assigns registrations to view - * - * @test */ + #[Test] public function listActionFetchesRegistrationsFromRepositoryAndAssignsThemToView(): void { $registrations = $this->getMockBuilder(ObjectStorage::class) @@ -84,9 +84,7 @@ public function listActionFetchesRegistrationsFromRepositoryAndAssignsThemToView $this->subject->listAction(); } - /** - * @test - */ + #[Test] public function detailActionThrowsExpectedExceptionIfRegistrationDoesNotBelongToFrontendUser(): void { $GLOBALS['TSFE'] = $this->createMock(TypoScriptFrontendController::class); @@ -104,9 +102,7 @@ public function detailActionThrowsExpectedExceptionIfRegistrationDoesNotBelongTo $this->subject->detailAction($registration); } - /** - * @test - */ + #[Test] public function detailActionAssignsRegistrationToViewIfRegistrationBelongsToFrontendUser(): void { $GLOBALS['TSFE'] = $this->createMock(TypoScriptFrontendController::class); diff --git a/Tests/Unit/Domain/Model/CustomNotificationLogTest.php b/Tests/Unit/Domain/Model/CustomNotificationLogTest.php index 65b1f9a84..680e875ec 100644 --- a/Tests/Unit/Domain/Model/CustomNotificationLogTest.php +++ b/Tests/Unit/Domain/Model/CustomNotificationLogTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Domain\Model; +use PHPUnit\Framework\Attributes\Test; use DateTime; use DERHANSEN\SfEventMgt\Domain\Model\CustomNotificationLog; use DERHANSEN\SfEventMgt\Domain\Model\Event; @@ -32,9 +33,8 @@ protected function tearDown(): void /** * Test if event can be set - * - * @test */ + #[Test] public function setEventForEventSetsEvent(): void { $event = new Event(); @@ -44,9 +44,8 @@ public function setEventForEventSetsEvent(): void /** * Test if details can be set - * - * @test */ + #[Test] public function setDetailsForStringSetsDetails(): void { $this->subject->setDetails('Description'); @@ -55,9 +54,8 @@ public function setDetailsForStringSetsDetails(): void /** * Test if emailsSent can be set - * - * @test */ + #[Test] public function setEmailsSentForIntSetsEmailsSent(): void { $this->subject->setEmailsSent(100); @@ -66,9 +64,8 @@ public function setEmailsSentForIntSetsEmailsSent(): void /** * Test if tstamp can be set - * - * @test */ + #[Test] public function setTstampForDateTimeSetsTstamp(): void { $tstamp = new DateTime('01.01.2014 10:00:00'); @@ -78,26 +75,21 @@ public function setTstampForDateTimeSetsTstamp(): void /** * Test if backend user can be set to field cruser_id - * - * @test */ + #[Test] public function setCruserIdForBackendUserSetsBackendUserId(): void { $this->subject->setCruserId(1); self::assertEquals(1, $this->subject->getCruserId()); } - /** - * @test - */ + #[Test] public function getMessageReturnsInitialValueForString(): void { self::assertEquals('', $this->subject->getMessage()); } - /** - * @test - */ + #[Test] public function setMessageSetsMessage(): void { $this->subject->setMessage('test'); diff --git a/Tests/Unit/Domain/Model/Dto/CategoryDemandTest.php b/Tests/Unit/Domain/Model/Dto/CategoryDemandTest.php index 8755b9d6b..47cc07a64 100644 --- a/Tests/Unit/Domain/Model/Dto/CategoryDemandTest.php +++ b/Tests/Unit/Domain/Model/Dto/CategoryDemandTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Domain\Model\Dto; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Dto\CategoryDemand; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -28,34 +29,26 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function getStoragePageReturnsIntialValueForString(): void { self::assertEquals('', $this->subject->getStoragePage()); } - /** - * @test - */ + #[Test] public function setStoragePageSetsStoragePageForString(): void { $this->subject->setStoragePage('1,2,3'); self::assertEquals('1,2,3', $this->subject->getStoragePage()); } - /** - * @test - */ + #[Test] public function getRestrictStoragePageReturnsInitialValue(): void { self::assertFalse($this->subject->getRestrictToStoragePage()); } - /** - * @test - */ + #[Test] public function setRestrictStoragePageSetsValueForBoolean(): void { $this->subject->setRestrictToStoragePage(true); @@ -67,69 +60,53 @@ public function getCategoriesReturnsInitialValueForString(): void self::assertEquals('', $this->subject->getCategories()); } - /** - * @test - */ + #[Test] public function setCategoriesSetsCategoriesForString(): void { $this->subject->setCategories('1,2,3'); self::assertEquals('1,2,3', $this->subject->getCategories()); } - /** - * @test - */ + #[Test] public function getIncludeSubcategoriesReturnsInitialValue(): void { self::assertFalse($this->subject->getIncludeSubcategories()); } - /** - * @test - */ + #[Test] public function setIncludeSubcategoriesSetsValueForBoolean(): void { $this->subject->setIncludeSubcategories(true); self::assertTrue($this->subject->getIncludeSubcategories()); } - /** - * @test - */ + #[Test] public function orderFieldReturnsDefaultValue(): void { self::assertSame('uid', $this->subject->getOrderField()); } - /** - * @test - */ + #[Test] public function orderFieldCanBeSet(): void { $this->subject->setOrderField('title'); self::assertSame('title', $this->subject->getOrderField()); } - /** - * @test - */ + #[Test] public function orderDirectionReturnsDefaultValue(): void { self::assertSame('asc', $this->subject->getOrderDirection()); } - /** - * @test - */ + #[Test] public function orderDirectionCanBeSet(): void { $this->subject->setOrderDirection('desc'); self::assertSame('desc', $this->subject->getOrderDirection()); } - /** - * @test - */ + #[Test] public function createFromSettingsReturnsExpectedObjectIfEmptySettings(): void { $expected = new CategoryDemand(); @@ -138,9 +115,7 @@ public function createFromSettingsReturnsExpectedObjectIfEmptySettings(): void self::assertEquals($expected, $current); } - /** - * @test - */ + #[Test] public function createFromSettingsReturnsExpectedObjectWithSettings(): void { $expected = new CategoryDemand(); diff --git a/Tests/Unit/Domain/Model/Dto/CustomNotificationTest.php b/Tests/Unit/Domain/Model/Dto/CustomNotificationTest.php index 94b464a95..88f75c5d4 100644 --- a/Tests/Unit/Domain/Model/Dto/CustomNotificationTest.php +++ b/Tests/Unit/Domain/Model/Dto/CustomNotificationTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Domain\Model\Dto; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Dto\CustomNotification; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -28,68 +29,52 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function getTemplateReturnsInitialValue(): void { self::assertEquals('', $this->subject->getTemplate()); } - /** - * @test - */ + #[Test] public function setTemplateSetsValueForString(): void { $this->subject->setTemplate('a-template'); self::assertEquals('a-template', $this->subject->getTemplate()); } - /** - * @test - */ + #[Test] public function getRecipientsReturnsInitialValue(): void { self::assertEquals(CustomNotification::RECIPIENTS_CONFIRMED, $this->subject->getRecipients()); } - /** - * @test - */ + #[Test] public function setRecipientsSetsValueForInteger(): void { $this->subject->setRecipients(CustomNotification::RECIPIENTS_ALL); self::assertEquals(CustomNotification::RECIPIENTS_ALL, $this->subject->getRecipients()); } - /** - * @test - */ + #[Test] public function getOverwriteSubjectReturnsInitialValue(): void { self::assertEquals('', $this->subject->getOverwriteSubject()); } - /** - * @test - */ + #[Test] public function setOverwriteSubjectSetsValueForString(): void { $this->subject->setOverwriteSubject('subject'); self::assertEquals('subject', $this->subject->getOverwriteSubject()); } - /** - * @test - */ + #[Test] public function getAdditionalMessageReturnsInitialValue(): void { self::assertEquals('', $this->subject->getAdditionalMessage()); } - /** - * @test - */ + #[Test] public function setAdditionalMessageSetsValueForString(): void { $this->subject->setAdditionalMessage('message'); diff --git a/Tests/Unit/Domain/Model/Dto/EventDemandTest.php b/Tests/Unit/Domain/Model/Dto/EventDemandTest.php index 4d472ffaf..654a3a3f6 100644 --- a/Tests/Unit/Domain/Model/Dto/EventDemandTest.php +++ b/Tests/Unit/Domain/Model/Dto/EventDemandTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Domain\Model\Dto; +use PHPUnit\Framework\Attributes\Test; use DateTime; use DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand; use DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand; @@ -33,9 +34,7 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function getDisplayModeReturnsInitialValue(): void { self::assertSame( @@ -44,9 +43,7 @@ public function getDisplayModeReturnsInitialValue(): void ); } - /** - * @test - */ + #[Test] public function getTopEventRestrictionReturnsInitialValueForInteger(): void { self::assertSame( @@ -55,9 +52,7 @@ public function getTopEventRestrictionReturnsInitialValueForInteger(): void ); } - /** - * @test - */ + #[Test] public function setTopEventRestrictionForIntegerSetsTopEventRestriction(): void { $this->subject->setTopEventRestriction(1); @@ -67,18 +62,14 @@ public function setTopEventRestrictionForIntegerSetsTopEventRestriction(): void ); } - /** - * @test - */ + #[Test] public function setDisplayModeForStringSetsDisplayMode(): void { $this->subject->setDisplayMode('past'); self::assertEquals('past', $this->subject->getDisplayMode()); } - /** - * @test - */ + #[Test] public function getStoragePageReturnsInitialValue(): void { self::assertSame( @@ -87,18 +78,14 @@ public function getStoragePageReturnsInitialValue(): void ); } - /** - * @test - */ + #[Test] public function setStoragePageForStringSetsStoragePage(): void { $this->subject->setStoragePage('1,2,3'); self::assertEquals('1,2,3', $this->subject->getStoragePage()); } - /** - * @test - */ + #[Test] public function getCurrentDateTimeReturnsGivenValueIfValueSet(): void { $this->subject->setCurrentDateTime(new DateTime('01.01.2014')); @@ -108,17 +95,13 @@ public function getCurrentDateTimeReturnsGivenValueIfValueSet(): void ); } - /** - * @test - */ + #[Test] public function getCategoryReturnsInitialValue(): void { self::assertEquals('', $this->subject->getCategory()); } - /** - * @test - */ + #[Test] public function getCategoryForStringSetsCategory(): void { $this->subject->setCategory('1,2,3,4'); @@ -128,17 +111,13 @@ public function getCategoryForStringSetsCategory(): void ); } - /** - * @test - */ + #[Test] public function setIncludeSubcategoriesReturnsInitialValueForBoolean(): void { self::assertFalse($this->subject->getIncludeSubcategories()); } - /** - * @test - */ + #[Test] public function getOrderFieldReturnsEmptyStringIfNoValueSet(): void { self::assertSame( @@ -147,9 +126,7 @@ public function getOrderFieldReturnsEmptyStringIfNoValueSet(): void ); } - /** - * @test - */ + #[Test] public function getOrderFieldReturnsGivenValueIfValueSet(): void { $this->subject->setOrderField('title'); @@ -159,9 +136,7 @@ public function getOrderFieldReturnsGivenValueIfValueSet(): void ); } - /** - * @test - */ + #[Test] public function getOrderDirectionReturnsEmptyStringIfNoValueSet(): void { self::assertSame( @@ -170,9 +145,7 @@ public function getOrderDirectionReturnsEmptyStringIfNoValueSet(): void ); } - /** - * @test - */ + #[Test] public function getOrderDirectionReturnsGivenValueIfValueSet(): void { $this->subject->setOrderDirection('asc'); @@ -182,17 +155,13 @@ public function getOrderDirectionReturnsGivenValueIfValueSet(): void ); } - /** - * @test - */ + #[Test] public function getQueryLimitReturnsNullIfNoValueSet(): void { self::assertEquals(0, $this->subject->getQueryLimit()); } - /** - * @test - */ + #[Test] public function getQueryLimitReturnsExpectedQueryLimit(): void { $this->subject->setQueryLimit(10); @@ -202,17 +171,13 @@ public function getQueryLimitReturnsExpectedQueryLimit(): void ); } - /** - * @test - */ + #[Test] public function getLocationReturnsNullIfNoValueSet(): void { self::assertNull($this->subject->getLocation()); } - /** - * @test - */ + #[Test] public function getLocationReturnsExpectedLocation(): void { $location = new Location(); @@ -225,9 +190,8 @@ public function getLocationReturnsExpectedLocation(): void /** * Test if default value is returned - * - * @test */ + #[Test] public function getLocationCityReturnsDefaultValue(): void { self::assertSame('', $this->subject->getLocationCity()); @@ -235,9 +199,8 @@ public function getLocationCityReturnsDefaultValue(): void /** * Test if value can be set - * - * @test */ + #[Test] public function getLocationCityReturnsExpectedValue(): void { $this->subject->setLocationCity('Flensburg'); @@ -246,9 +209,8 @@ public function getLocationCityReturnsExpectedValue(): void /** * Test if default value is returned - * - * @test */ + #[Test] public function getLocationCountryReturnsDefaultValue(): void { self::assertSame('', $this->subject->getLocationCountry()); @@ -256,111 +218,86 @@ public function getLocationCountryReturnsDefaultValue(): void /** * Test if value can be set - * - * @test */ + #[Test] public function getLocationCountryReturnsExpectedValue(): void { $this->subject->setLocationCountry('Germany'); self::assertSame('Germany', $this->subject->getLocationCountry()); } - /** - * @test - */ + #[Test] public function getYearReturnsDefaultValue(): void { self::assertEquals(0, $this->subject->getYear()); } - /** - * @test - */ + #[Test] public function setYearSetsYearForInteger(): void { $this->subject->setYear(2017); self::assertSame(2017, $this->subject->getYear()); } - /** - * @test - */ + #[Test] public function getMonthReturnsDefaultValue(): void { self::assertEquals(0, $this->subject->getMonth()); } - /** - * @test - */ + #[Test] public function setMonthSetsMonthForInteger(): void { $this->subject->setMonth(12); self::assertSame(12, $this->subject->getMonth()); } - /** - * @test - */ + #[Test] public function getDayReturnsDefaultValue(): void { self::assertEquals(0, $this->subject->getDay()); } - /** - * @test - */ + #[Test] public function setDaySetsDayForInteger(): void { $this->subject->setDay(1); self::assertSame(1, $this->subject->getDay()); } - /** - * @test - */ + #[Test] public function getCategoryConjuctionReturnsInitialValue(): void { self::assertSame('', $this->subject->getCategoryConjunction()); } - /** - * @test - */ + #[Test] public function getCategoryConjuctionSetsCategoryConjunctionForString(): void { $this->subject->setCategoryConjunction('AND'); self::assertSame('AND', $this->subject->getCategoryConjunction()); } - /** - * @test - */ + #[Test] public function getIgnoreEnableFieldsReturnsDefaultValue(): void { self::assertFalse($this->subject->getIgnoreEnableFields()); } - /** - * @test - */ + #[Test] public function setIgnoreEnableFieldsSetsValueForBoolean(): void { $this->subject->setIgnoreEnableFields(true); self::assertTrue($this->subject->getIgnoreEnableFields()); } - /** - * @test - */ + #[Test] public function getSearchDemandReturnsInitialValue(): void { self::assertNull($this->subject->getSearchDemand()); } - /** - * @test - */ + #[Test] public function searchDemandCanBeSet(): void { $searchDemamd = new SearchDemand(); @@ -368,17 +305,13 @@ public function searchDemandCanBeSet(): void self::assertSame($searchDemamd, $this->subject->getSearchDemand()); } - /** - * @test - */ + #[Test] public function getOrganisatorReturnsInitialValue(): void { self::assertNull($this->subject->getOrganisator()); } - /** - * @test - */ + #[Test] public function organisatorCanBeSet(): void { $organisator = new Organisator(); @@ -386,35 +319,27 @@ public function organisatorCanBeSet(): void self::assertSame($organisator, $this->subject->getOrganisator()); } - /** - * @test - */ + #[Test] public function getIncludeCurrentReturnsInitialValue(): void { self::assertFalse($this->subject->getIncludeCurrent()); } - /** - * @test - */ + #[Test] public function includeCurrentCanBeSet(): void { $this->subject->setIncludeCurrent(true); self::assertTrue($this->subject->getIncludeCurrent()); } - /** - * @test - */ + #[Test] public function createFromSettingsReturnsExpectedObjectIfEmptySettings(): void { $expected = new EventDemand(); self::assertEquals($expected, EventDemand::createFromSettings()); } - /** - * @test - */ + #[Test] public function createFromSettingsReturnsExpectedObjectWithSettings(): void { $location = new Location(); diff --git a/Tests/Unit/Domain/Model/Dto/ForeignRecordDemandTest.php b/Tests/Unit/Domain/Model/Dto/ForeignRecordDemandTest.php index 949ddc52c..582755f2e 100644 --- a/Tests/Unit/Domain/Model/Dto/ForeignRecordDemandTest.php +++ b/Tests/Unit/Domain/Model/Dto/ForeignRecordDemandTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Domain\Model\Dto; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Dto\ForeignRecordDemand; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -28,52 +29,40 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function getStoragePageReturnsInitialValue(): void { self::assertEquals('', $this->subject->getStoragePage()); } - /** - * @test - */ + #[Test] public function setStoragePageSetsStoragePageForString(): void { $this->subject->setStoragePage('1,2,3'); self::assertEquals('1,2,3', $this->subject->getStoragePage()); } - /** - * @test - */ + #[Test] public function getrestrictForeignRecordsToStoragePageReturnsInitialValue(): void { self::assertFalse($this->subject->getRestrictForeignRecordsToStoragePage()); } - /** - * @test - */ + #[Test] public function setRestrictForeignRecordsToStoragePageSetsValueForBoolean(): void { $this->subject->setRestrictForeignRecordsToStoragePage(true); self::assertTrue($this->subject->getRestrictForeignRecordsToStoragePage()); } - /** - * @test - */ + #[Test] public function createFromSettingsReturnsExpectedObjectIfEmptySettings(): void { $expected = new ForeignRecordDemand(); self::assertEquals($expected, ForeignRecordDemand::createFromSettings()); } - /** - * @test - */ + #[Test] public function createFromSettingsReturnsExpectedObjectWithSettings(): void { $expected = new ForeignRecordDemand(); diff --git a/Tests/Unit/Domain/Model/Dto/SearchDemandTest.php b/Tests/Unit/Domain/Model/Dto/SearchDemandTest.php index 89a49f182..f6d7787aa 100644 --- a/Tests/Unit/Domain/Model/Dto/SearchDemandTest.php +++ b/Tests/Unit/Domain/Model/Dto/SearchDemandTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Domain\Model\Dto; +use PHPUnit\Framework\Attributes\Test; use DateTime; use DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -29,9 +30,7 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function getStartDateReturnsNullIfNoValueSet(): void { self::assertNull( @@ -39,9 +38,7 @@ public function getStartDateReturnsNullIfNoValueSet(): void ); } - /** - * @test - */ + #[Test] public function getStartDateReturnsGivenValueIfValueSet(): void { $this->subject->setStartDate(new DateTime('01.01.2014 10:00:00')); @@ -51,9 +48,7 @@ public function getStartDateReturnsGivenValueIfValueSet(): void ); } - /** - * @test - */ + #[Test] public function getEndDateReturnsNullIfNoValueSet(): void { self::assertNull( @@ -61,9 +56,7 @@ public function getEndDateReturnsNullIfNoValueSet(): void ); } - /** - * @test - */ + #[Test] public function getEndDateReturnsGivenValueIfValueSet(): void { $this->subject->setEndDate(new DateTime('01.01.2014 10:00:00')); @@ -73,17 +66,13 @@ public function getEndDateReturnsGivenValueIfValueSet(): void ); } - /** - * @test - */ + #[Test] public function getSearchReturnsEmptyStringIfNotSet(): void { self::assertEquals('', $this->subject->getSearch()); } - /** - * @test - */ + #[Test] public function getSearchReturnsGivenValueIfSet(): void { $this->subject->setSearch('Test'); @@ -93,17 +82,13 @@ public function getSearchReturnsGivenValueIfSet(): void ); } - /** - * @test - */ + #[Test] public function getFieldsReturnsEmptyStringIfNotSet(): void { self::assertEmpty($this->subject->getFields()); } - /** - * @test - */ + #[Test] public function getFieldsReturnsGivenValueIfSet(): void { $this->subject->setFields('Field1,Field2'); @@ -113,44 +98,34 @@ public function getFieldsReturnsGivenValueIfSet(): void ); } - /** - * @test - */ + #[Test] public function getHasQueryReturnsFalseIfNoQuerySet(): void { self::assertFalse($this->subject->getHasQuery()); } - /** - * @test - */ + #[Test] public function getHasQueryReturnsTrueIfSearchSet(): void { $this->subject->setSearch('Test'); self::assertTrue($this->subject->getHasQuery()); } - /** - * @test - */ + #[Test] public function getHasQueryReturnsTrueIfStartDateSet(): void { $this->subject->setStartDate(new DateTime()); self::assertTrue($this->subject->getHasQuery()); } - /** - * @test - */ + #[Test] public function getHasQueryReturnsTrueIfEndDateSet(): void { $this->subject->setEndDate(new DateTime()); self::assertTrue($this->subject->getHasQuery()); } - /** - * @test - */ + #[Test] public function toArrayReturnsExpectedArray(): void { $startDate = new DateTime('01.01.2020 00:00'); @@ -172,18 +147,14 @@ public function toArrayReturnsExpectedArray(): void self::assertEquals($expected, $searchDemand->toArray()); } - /** - * @test - */ + #[Test] public function fromArrayReturnsExpectedObjectForEmptyData(): void { $searchDemand = new SearchDemand(); self::assertEquals($searchDemand, SearchDemand::fromArray([])); } - /** - * @test - */ + #[Test] public function fromArrayReturnsExpectedObjectForGivenData(): void { $startDate = new DateTime('01.01.2020 00:00'); diff --git a/Tests/Unit/Domain/Model/Dto/UserRegistrationDemandTest.php b/Tests/Unit/Domain/Model/Dto/UserRegistrationDemandTest.php index 402c7ba2e..6cd30967b 100644 --- a/Tests/Unit/Domain/Model/Dto/UserRegistrationDemandTest.php +++ b/Tests/Unit/Domain/Model/Dto/UserRegistrationDemandTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Domain\Model\Dto; +use PHPUnit\Framework\Attributes\Test; use DateTime; use DERHANSEN\SfEventMgt\Domain\Model\Dto\UserRegistrationDemand; use DERHANSEN\SfEventMgt\Domain\Model\FrontendUser; @@ -30,9 +31,7 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function getDisplayModeReturnsInitialValue(): void { self::assertSame( @@ -41,43 +40,33 @@ public function getDisplayModeReturnsInitialValue(): void ); } - /** - * @test - */ + #[Test] public function setDisplayModeForStringSetsDisplayMode(): void { $this->subject->setDisplayMode('past'); self::assertEquals('past', $this->subject->getDisplayMode()); } - /** - * @test - */ + #[Test] public function getStoragePageReturnsInitialValue(): void { self::assertEquals('', $this->subject->getStoragePage()); } - /** - * @test - */ + #[Test] public function setStoragePageForStringSetsStoragePage(): void { $this->subject->setStoragePage('1,2,3'); self::assertEquals('1,2,3', $this->subject->getStoragePage()); } - /** - * @test - */ + #[Test] public function getCurrentDateTimeReturnsDateTimeObjectIfNoValueSet(): void { self::assertInstanceOf('DateTime', $this->subject->getCurrentDateTime()); } - /** - * @test - */ + #[Test] public function getCurrentDateTimeReturnsGivenValueIfValueSet(): void { $this->subject->setCurrentDateTime(new DateTime('01.01.2014')); @@ -87,9 +76,7 @@ public function getCurrentDateTimeReturnsGivenValueIfValueSet(): void ); } - /** - * @test - */ + #[Test] public function getOrderFieldReturnsEmptyStringIfNoValueSet(): void { self::assertSame( @@ -98,9 +85,7 @@ public function getOrderFieldReturnsEmptyStringIfNoValueSet(): void ); } - /** - * @test - */ + #[Test] public function getOrderFieldReturnsGivenValueIfValueSet(): void { $this->subject->setOrderField('title'); @@ -110,9 +95,7 @@ public function getOrderFieldReturnsGivenValueIfValueSet(): void ); } - /** - * @test - */ + #[Test] public function getOrderDirectionReturnsEmptyStringIfNoValueSet(): void { self::assertSame( @@ -121,9 +104,7 @@ public function getOrderDirectionReturnsEmptyStringIfNoValueSet(): void ); } - /** - * @test - */ + #[Test] public function getOrderDirectionReturnsGivenValueIfValueSet(): void { $this->subject->setOrderDirection('asc'); @@ -133,17 +114,13 @@ public function getOrderDirectionReturnsGivenValueIfValueSet(): void ); } - /** - * @test - */ + #[Test] public function getUserReturnsInitialValue(): void { self::assertNull($this->subject->getUser()); } - /** - * @test - */ + #[Test] public function setUserSetsUser(): void { $user = new FrontendUser(); @@ -151,9 +128,7 @@ public function setUserSetsUser(): void self::assertSame($this->subject->getUser(), $user); } - /** - * @test - */ + #[Test] public function createFromSettingsReturnsExpectedObjectIfEmptySettings(): void { $expected = new UserRegistrationDemand(); @@ -162,9 +137,7 @@ public function createFromSettingsReturnsExpectedObjectIfEmptySettings(): void self::assertEquals($expected, $current); } - /** - * @test - */ + #[Test] public function createFromSettingsReturnsExpectedObjectWithSettings(): void { $expected = new UserRegistrationDemand(); diff --git a/Tests/Unit/Domain/Model/EventTest.php b/Tests/Unit/Domain/Model/EventTest.php index dd880450e..793bb3d75 100644 --- a/Tests/Unit/Domain/Model/EventTest.php +++ b/Tests/Unit/Domain/Model/EventTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Domain\Model; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; use DateInterval; use DateTime; use DERHANSEN\SfEventMgt\Domain\Model\Category; @@ -42,9 +44,7 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function getTitleReturnsInitialValueForString(): void { self::assertSame( @@ -53,18 +53,14 @@ public function getTitleReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setTitleForStringSetsTitle(): void { $this->subject->setTitle('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->getTitle()); } - /** - * @test - */ + #[Test] public function getDescriptionReturnsInitialValueForString(): void { self::assertSame( @@ -73,18 +69,14 @@ public function getDescriptionReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setDescriptionForStringSetsDescription(): void { $this->subject->setDescription('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->getDescription()); } - /** - * @test - */ + #[Test] public function getProgramReturnsInitialValueForString(): void { self::assertSame( @@ -93,35 +85,27 @@ public function getProgramReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setProgramForStringSetsProgram(): void { $this->subject->setProgram('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->getProgram()); } - /** - * @test - */ + #[Test] public function getCustomTextReturnsInitialValueForString(): void { self::assertSame('', $this->subject->getCustomText()); } - /** - * @test - */ + #[Test] public function setCustomTextForStringSetsCustomText(): void { $this->subject->setCustomText('A custom text'); self::assertEquals('A custom text', $this->subject->getCustomText()); } - /** - * @test - */ + #[Test] public function getTeaserReturnsInitialValueForString(): void { self::assertSame( @@ -130,18 +114,14 @@ public function getTeaserReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setTeaserForStringSetsTeaser(): void { $this->subject->setTeaser('This is a teaser'); self::assertEquals('This is a teaser', $this->subject->getTeaser()); } - /** - * @test - */ + #[Test] public function getStartdateReturnsInitialValueForDateTime(): void { self::assertNull( @@ -149,9 +129,7 @@ public function getStartdateReturnsInitialValueForDateTime(): void ); } - /** - * @test - */ + #[Test] public function setStartdateForDateTimeSetsStartdate(): void { $dateTimeFixture = new DateTime(); @@ -159,9 +137,7 @@ public function setStartdateForDateTimeSetsStartdate(): void self::assertEquals($dateTimeFixture, $this->subject->getStartdate()); } - /** - * @test - */ + #[Test] public function getEnddateReturnsInitialValueForDateTime(): void { self::assertNull( @@ -169,9 +145,7 @@ public function getEnddateReturnsInitialValueForDateTime(): void ); } - /** - * @test - */ + #[Test] public function setEnddateForDateTimeSetsEnddate(): void { $dateTimeFixture = new DateTime(); @@ -179,9 +153,7 @@ public function setEnddateForDateTimeSetsEnddate(): void self::assertEquals($dateTimeFixture, $this->subject->getEnddate()); } - /** - * @test - */ + #[Test] public function getParticipantsReturnsInitialValueForInteger(): void { self::assertSame( @@ -190,9 +162,7 @@ public function getParticipantsReturnsInitialValueForInteger(): void ); } - /** - * @test - */ + #[Test] public function getTopEventReturnsInitialValueForBoolean(): void { self::assertFalse( @@ -200,18 +170,14 @@ public function getTopEventReturnsInitialValueForBoolean(): void ); } - /** - * @test - */ + #[Test] public function setParticipantsForIntegerSetsParticipants(): void { $this->subject->setMaxParticipants(12); self::assertEquals(12, $this->subject->getMaxParticipants()); } - /** - * @test - */ + #[Test] public function getPriceReturnsInitialValueForFloat(): void { self::assertSame( @@ -220,18 +186,14 @@ public function getPriceReturnsInitialValueForFloat(): void ); } - /** - * @test - */ + #[Test] public function setPriceForFloatSetsPrice(): void { $this->subject->setPrice(3.99); self::assertEquals(3.99, $this->subject->getPrice()); } - /** - * @test - */ + #[Test] public function getCurrencyReturnsInitialValueForString(): void { self::assertSame( @@ -240,18 +202,14 @@ public function getCurrencyReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setCurrencyForStringSetsCurrency(): void { $this->subject->setCurrency('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->getCurrency()); } - /** - * @test - */ + #[Test] public function getCategoryReturnsInitialValueForCategory(): void { $newObjectStorage = new ObjectStorage(); @@ -261,9 +219,7 @@ public function getCategoryReturnsInitialValueForCategory(): void ); } - /** - * @test - */ + #[Test] public function setCategoryForObjectStorageContainingCategorySetsCategory(): void { $category = new Category(); @@ -273,9 +229,7 @@ public function setCategoryForObjectStorageContainingCategorySetsCategory(): voi self::assertEquals($objectStorageHoldingExactlyOneCategory, $this->subject->getCategory()); } - /** - * @test - */ + #[Test] public function addCategoryToObjectStorageHoldingCategory(): void { $category = new Category(); @@ -288,9 +242,7 @@ public function addCategoryToObjectStorageHoldingCategory(): void self::assertEquals($objectStorage, $this->subject->getCategory()); } - /** - * @test - */ + #[Test] public function removeCategoryFromObjectStorageHoldingCategory(): void { $category = new Category(); @@ -303,9 +255,7 @@ public function removeCategoryFromObjectStorageHoldingCategory(): void self::assertEmpty($this->subject->getCategory()); } - /** - * @test - */ + #[Test] public function getCategoriesReturnsTheSameAsGetCategory(): void { $category = new Category(); @@ -319,9 +269,7 @@ public function getCategoriesReturnsTheSameAsGetCategory(): void self::assertEquals($objectStorage, $this->subject->getCategories()); } - /** - * @test - */ + #[Test] public function getRegistrationReturnsInitialValueForRegistration(): void { $newObjectStorage = new ObjectStorage(); @@ -331,9 +279,7 @@ public function getRegistrationReturnsInitialValueForRegistration(): void ); } - /** - * @test - */ + #[Test] public function setRegistrationForObjectStorageContainingRegistrationSetsRegistration(): void { $registration = new Registration(); @@ -343,9 +289,7 @@ public function setRegistrationForObjectStorageContainingRegistrationSetsRegistr self::assertEquals($objectStorageHoldingExactlyOneRegistration, $this->subject->getRegistration()); } - /** - * @test - */ + #[Test] public function addRegistrationToObjectStorageHoldingRegistration(): void { $registration = new Registration(); @@ -358,9 +302,7 @@ public function addRegistrationToObjectStorageHoldingRegistration(): void self::assertEquals($objectStorage, $this->subject->getRegistration()); } - /** - * @test - */ + #[Test] public function removeRegistrationFromObjectStorageHoldingRegistration(): void { $registration = new Registration(); @@ -373,9 +315,7 @@ public function removeRegistrationFromObjectStorageHoldingRegistration(): void self::assertEmpty($this->subject->getRegistration()); } - /** - * @test - */ + #[Test] public function getRegistrationWaitlistReturnsInitialValueForRegistrationWaitlist(): void { $newObjectStorage = new ObjectStorage(); @@ -385,9 +325,7 @@ public function getRegistrationWaitlistReturnsInitialValueForRegistrationWaitlis ); } - /** - * @test - */ + #[Test] public function setRegistrationWaitlistForObjectStorageContainingRegistrationSetsRegistrationWaitlist(): void { $registration = new Registration(); @@ -397,9 +335,7 @@ public function setRegistrationWaitlistForObjectStorageContainingRegistrationSet self::assertEquals($objectStorageHoldingExactlyOneRegistration, $this->subject->getRegistrationWaitlist()); } - /** - * @test - */ + #[Test] public function addRegistrationWaitlistToObjectStorageHoldingRegistrationWaitlist(): void { $registration = new Registration(); @@ -412,9 +348,7 @@ public function addRegistrationWaitlistToObjectStorageHoldingRegistrationWaitlis self::assertEquals($objectStorage, $this->subject->getRegistrationWaitlist()); } - /** - * @test - */ + #[Test] public function removeRegistrationWaitlistFromObjectStorageHoldingRegistrationWaitlist(): void { $registration = new Registration(); @@ -427,9 +361,7 @@ public function removeRegistrationWaitlistFromObjectStorageHoldingRegistrationWa self::assertEmpty($this->subject->getRegistrationWaitlist()); } - /** - * @test - */ + #[Test] public function getImageReturnsInitialValueForImage(): void { $newObjectStorage = new ObjectStorage(); @@ -439,9 +371,7 @@ public function getImageReturnsInitialValueForImage(): void ); } - /** - * @test - */ + #[Test] public function setImageForObjectStorageContainingImageSetsImage(): void { $image = new FileReference(); @@ -451,9 +381,7 @@ public function setImageForObjectStorageContainingImageSetsImage(): void self::assertEquals($objectStorageHoldingExactlyOneImage, $this->subject->getImage()); } - /** - * @test - */ + #[Test] public function addImageToObjectStorageHoldingImage(): void { $fileReference = new FileReference(); @@ -466,9 +394,7 @@ public function addImageToObjectStorageHoldingImage(): void self::assertEquals($objectStorage, $this->subject->getImage()); } - /** - * @test - */ + #[Test] public function removeImageFromObjectStorageHoldingImage(): void { $fileReference = new FileReference(); @@ -481,9 +407,7 @@ public function removeImageFromObjectStorageHoldingImage(): void self::assertEmpty($this->subject->getImage()); } - /** - * @test - */ + #[Test] public function getFilesReturnsInitialValueForfiles(): void { $newObjectStorage = new ObjectStorage(); @@ -493,9 +417,7 @@ public function getFilesReturnsInitialValueForfiles(): void ); } - /** - * @test - */ + #[Test] public function setFilesForObjectStorageContainingFilesSetsFiles(): void { $file = new FileReference(); @@ -505,9 +427,7 @@ public function setFilesForObjectStorageContainingFilesSetsFiles(): void self::assertEquals($objectStorageHoldingExactlyOneFile, $this->subject->getFiles()); } - /** - * @test - */ + #[Test] public function addFilesToObjectStorageHoldingFiles(): void { $fileReference = new FileReference(); @@ -520,9 +440,7 @@ public function addFilesToObjectStorageHoldingFiles(): void self::assertEquals($objectStorage, $this->subject->getFiles()); } - /** - * @test - */ + #[Test] public function removeFilesFromObjectStorageHoldingFiles(): void { $fileReference = new FileReference(); @@ -535,9 +453,7 @@ public function removeFilesFromObjectStorageHoldingFiles(): void self::assertEmpty($this->subject->getFiles()); } - /** - * @test - */ + #[Test] public function getAdditionalImageReturnsInitialValueForfiles(): void { $newObjectStorage = new ObjectStorage(); @@ -547,9 +463,7 @@ public function getAdditionalImageReturnsInitialValueForfiles(): void ); } - /** - * @test - */ + #[Test] public function setAdditionalImageForObjectStorageContainingFilesSetsFiles(): void { $file = new FileReference(); @@ -559,9 +473,7 @@ public function setAdditionalImageForObjectStorageContainingFilesSetsFiles(): vo self::assertEquals($objectStorageHoldingExactlyOneFile, $this->subject->getAdditionalImage()); } - /** - * @test - */ + #[Test] public function addAdditionalImageToObjectStorageHoldingFiles(): void { $fileReference = new FileReference(); @@ -574,9 +486,7 @@ public function addAdditionalImageToObjectStorageHoldingFiles(): void self::assertEquals($objectStorage, $this->subject->getAdditionalImage()); } - /** - * @test - */ + #[Test] public function removeAdditionalImageFromObjectStorageHoldingFiles(): void { $fileReference = new FileReference(); @@ -589,9 +499,7 @@ public function removeAdditionalImageFromObjectStorageHoldingFiles(): void self::assertEmpty($this->subject->getAdditionalImage()); } - /** - * @test - */ + #[Test] public function getRegistrationPossibleReturnsFalseIfEventHasTakenPlace(): void { $startdate = new DateTime(); @@ -602,9 +510,7 @@ public function getRegistrationPossibleReturnsFalseIfEventHasTakenPlace(): void self::assertFalse($this->subject->getRegistrationPossible()); } - /** - * @test - */ + #[Test] public function getRegistrationPossibleReturnsTrueIfEventHasStartedAndRegistrationUntilEnddateIsAllowed(): void { $startdate = new DateTime(); @@ -619,9 +525,7 @@ public function getRegistrationPossibleReturnsTrueIfEventHasStartedAndRegistrati self::assertTrue($this->subject->getRegistrationPossible()); } - /** - * @test - */ + #[Test] public function getRegistrationPossibleReturnsFalseIfEventHasEndedAndRegistrationUntilEnddateIsAllowed(): void { $startdate = new DateTime(); @@ -636,9 +540,7 @@ public function getRegistrationPossibleReturnsFalseIfEventHasEndedAndRegistratio self::assertFalse($this->subject->getRegistrationPossible()); } - /** - * @test - */ + #[Test] public function getRegistrationPossibleReturnsFalseIfRegistrationNotEnabled(): void { $startdate = new DateTime(); @@ -649,9 +551,7 @@ public function getRegistrationPossibleReturnsFalseIfRegistrationNotEnabled(): v self::assertFalse($this->subject->getRegistrationPossible()); } - /** - * @test - */ + #[Test] public function getRegistrationPossibleReturnsFalseIfRegistrationDeadlineReached(): void { $startdate = new DateTime(); @@ -666,9 +566,7 @@ public function getRegistrationPossibleReturnsFalseIfRegistrationDeadlineReached self::assertFalse($this->subject->getRegistrationPossible()); } - /** - * @test - */ + #[Test] public function getRegistrationPossibleReturnsTrueIfRegistrationStartdateReached(): void { $startdate = new DateTime(); @@ -683,9 +581,7 @@ public function getRegistrationPossibleReturnsTrueIfRegistrationStartdateReached self::assertTrue($this->subject->getRegistrationPossible()); } - /** - * @test - */ + #[Test] public function getRegistrationPossibleReturnsFalseIfRegistrationStartdateNotReached(): void { $startdate = new DateTime(); @@ -700,9 +596,7 @@ public function getRegistrationPossibleReturnsFalseIfRegistrationStartdateNotRea self::assertFalse($this->subject->getRegistrationPossible()); } - /** - * @test - */ + #[Test] public function getRegistrationPossibleReturnsFalseIfEventMaxParticipantsReached(): void { $registration = new Registration(); @@ -718,9 +612,7 @@ public function getRegistrationPossibleReturnsFalseIfEventMaxParticipantsReached self::assertFalse($this->subject->getRegistrationPossible()); } - /** - * @test - */ + #[Test] public function getRegistrationPossibleReturnsTrueIfMaxParticipantsNotSet(): void { $startdate = new DateTime(); @@ -732,9 +624,7 @@ public function getRegistrationPossibleReturnsTrueIfMaxParticipantsNotSet(): voi self::assertTrue($this->subject->getRegistrationPossible()); } - /** - * @test - */ + #[Test] public function getRegistrationPossibleReturnsFalseIfMaxParticipantsSetAndEventFull(): void { $startdate = new DateTime(); @@ -751,9 +641,7 @@ public function getRegistrationPossibleReturnsFalseIfMaxParticipantsSetAndEventF self::assertFalse($this->subject->getRegistrationPossible()); } - /** - * @test - */ + #[Test] public function getRegistrationPossibleReturnsTrueIfMaxParticipantsSetAndWaitlistEnabled(): void { $startdate = new DateTime(); @@ -771,9 +659,7 @@ public function getRegistrationPossibleReturnsTrueIfMaxParticipantsSetAndWaitlis self::assertTrue($this->subject->getRegistrationPossible()); } - /** - * @test - */ + #[Test] public function getRegistrationPossibleReturnsTrueIfMaxParticipantsIsZero(): void { $startdate = new DateTime(); @@ -784,9 +670,7 @@ public function getRegistrationPossibleReturnsTrueIfMaxParticipantsIsZero(): voi self::assertTrue($this->subject->getRegistrationPossible()); } - /** - * @test - */ + #[Test] public function getRegistrationPossibleReturnsTrueIfRegistrationDeadlineNotReached(): void { $startdate = new DateTime(); @@ -801,9 +685,7 @@ public function getRegistrationPossibleReturnsTrueIfRegistrationDeadlineNotReach self::assertTrue($this->subject->getRegistrationPossible()); } - /** - * @test - */ + #[Test] public function getRegistrationPossibleReturnsTrueIfRegistrationIsLogicallyPossible(): void { $startdate = new DateTime(); @@ -815,9 +697,7 @@ public function getRegistrationPossibleReturnsTrueIfRegistrationIsLogicallyPossi self::assertTrue($this->subject->getRegistrationPossible()); } - /** - * @test - */ + #[Test] public function getLocationReturnsInitialValueForLocation(): void { self::assertNull( @@ -825,9 +705,7 @@ public function getLocationReturnsInitialValueForLocation(): void ); } - /** - * @test - */ + #[Test] public function setLocationSetsLocation(): void { $location = new Location(); @@ -835,9 +713,7 @@ public function setLocationSetsLocation(): void self::assertEquals($location, $this->subject->getLocation()); } - /** - * @test - */ + #[Test] public function getEnableRegistrationReturnsInitialValueForBoolean(): void { self::assertFalse( @@ -845,18 +721,14 @@ public function getEnableRegistrationReturnsInitialValueForBoolean(): void ); } - /** - * @test - */ + #[Test] public function setEnableRegistrationForBooleanSetsEnableRegistration(): void { $this->subject->setEnableRegistration(true); self::assertTrue($this->subject->getEnableRegistration()); } - /** - * @test - */ + #[Test] public function getEnableWaitlistReturnsInitialValueForBoolean(): void { self::assertFalse( @@ -864,18 +736,14 @@ public function getEnableWaitlistReturnsInitialValueForBoolean(): void ); } - /** - * @test - */ + #[Test] public function setEnableWaitlistForBooleanSetsEnableWaitlist(): void { $this->subject->setEnableWaitlist(true); self::assertTrue($this->subject->getEnableWaitlist()); } - /** - * @test - */ + #[Test] public function getEnableWaitlistMoveupReturnsInitialValueForBoolean(): void { self::assertFalse( @@ -883,18 +751,14 @@ public function getEnableWaitlistMoveupReturnsInitialValueForBoolean(): void ); } - /** - * @test - */ + #[Test] public function setEnableWaitlistMoveupForBooleanSetsEnableWaitlistMoveup(): void { $this->subject->setEnableWaitlistMoveup(true); self::assertTrue($this->subject->getEnableWaitlistMoveup()); } - /** - * @test - */ + #[Test] public function getLinkReturnsInitialValueForLink(): void { self::assertEquals( @@ -903,18 +767,14 @@ public function getLinkReturnsInitialValueForLink(): void ); } - /** - * @test - */ + #[Test] public function setLinkForStringSetsLink(): void { $this->subject->setLink('www.domain.tld'); self::assertEquals('www.domain.tld', $this->subject->getLink()); } - /** - * @test - */ + #[Test] public function getFreePlacesWithoutRegistrationsTest(): void { $this->subject->setMaxParticipants(10); @@ -925,9 +785,7 @@ public function getFreePlacesWithoutRegistrationsTest(): void ); } - /** - * @test - */ + #[Test] public function getFreePlacesWithRegistrationsTest(): void { $this->subject->setMaxParticipants(10); @@ -944,9 +802,7 @@ public function getFreePlacesWithRegistrationsTest(): void ); } - /** - * @test - */ + #[Test] public function getRegistrationDeadlineReturnsInitialValueForDateTime(): void { self::assertNull( @@ -954,9 +810,7 @@ public function getRegistrationDeadlineReturnsInitialValueForDateTime(): void ); } - /** - * @test - */ + #[Test] public function setRegistrationDeadlineForDateTimeSetsStartdate(): void { $dateTimeFixture = new DateTime(); @@ -964,26 +818,20 @@ public function setRegistrationDeadlineForDateTimeSetsStartdate(): void self::assertEquals($dateTimeFixture, $this->subject->getRegistrationDeadline()); } - /** - * @test - */ + #[Test] public function setTopEventForBooleanSetsTopEvent(): void { $this->subject->setTopEvent(true); self::assertTrue($this->subject->getTopEvent()); } - /** - * @test - */ + #[Test] public function maxRegistrationsPerUserReturnsInitialValue(): void { self::assertEquals(1, $this->subject->getMaxRegistrationsPerUser()); } - /** - * @test - */ + #[Test] public function maxRegistrationsPerUserSetsMaxRegistrationsPerUser(): void { $this->subject->setMaxRegistrationsPerUser(2); @@ -992,17 +840,14 @@ public function maxRegistrationsPerUserSetsMaxRegistrationsPerUser(): void /** * Test if initial value for organisator is returned - * - * @test */ + #[Test] public function getOrganisatorReturnsInitialValueForOrganisator(): void { self::assertNull($this->subject->getOrganisator()); } - /** - * @test - */ + #[Test] public function getRoomReturnsInitialValue(): void { self::assertEquals('', $this->subject->getRoom()); @@ -1016,9 +861,8 @@ public function setRoomSetsRoomForString(): void /** * Test if organisator can be set - * - * @test */ + #[Test] public function setPhoneForStringSetsPhone(): void { $organisator = new Organisator(); @@ -1028,9 +872,8 @@ public function setPhoneForStringSetsPhone(): void /** * Test if initial value for notifyAdmin (TRUE) is returned - * - * @test */ + #[Test] public function getNotityAdminReturnsInitialValue(): void { self::assertTrue($this->subject->getNotifyAdmin()); @@ -1038,9 +881,8 @@ public function getNotityAdminReturnsInitialValue(): void /** * Test if notifyAdmin can be set - * - * @test */ + #[Test] public function setNotifyAdminSetsValueForNotifyAdmin(): void { $this->subject->setNotifyAdmin(false); @@ -1049,9 +891,8 @@ public function setNotifyAdminSetsValueForNotifyAdmin(): void /** * Test if initial value for notifyOrganisator (FALSE) is returned - * - * @test */ + #[Test] public function getNotityOrganisatorReturnsInitialValue(): void { self::assertFalse($this->subject->getNotifyOrganisator()); @@ -1059,60 +900,47 @@ public function getNotityOrganisatorReturnsInitialValue(): void /** * Test if notifyOrganisator can be set - * - * @test */ + #[Test] public function setNotifyOrganisatorSetsValueForNotifyOrganisator(): void { $this->subject->setNotifyOrganisator(true); self::assertTrue($this->subject->getNotifyOrganisator()); } - /** - * @test - */ + #[Test] public function uniqueEmailCheckReturnsInitialValue(): void { self::assertFalse($this->subject->getUniqueEmailCheck()); } - /** - * @test - */ + #[Test] public function uniqueEmailCheckSetsValueForBoolen(): void { $this->subject->setUniqueEmailCheck(true); self::assertTrue($this->subject->getUniqueEmailCheck()); } - /** - * @test - */ + #[Test] public function enableCancelReturnsDefaultValue(): void { self::assertFalse($this->subject->getEnableCancel()); } - /** - * @test - */ + #[Test] public function setEnableCancelSetsEnableCancelForBoolean(): void { $this->subject->setEnableCancel(true); self::assertTrue($this->subject->getEnableCancel()); } - /** - * @test - */ + #[Test] public function getCancelDeallineReturnsDefaultValue(): void { self::assertEquals(0, $this->subject->getCancelDeadline()); } - /** - * @test - */ + #[Test] public function setCancelDeallineSetsCancelDeadlineForDate(): void { $date = new DateTime(); @@ -1120,60 +948,46 @@ public function setCancelDeallineSetsCancelDeadlineForDate(): void self::assertEquals($date, $this->subject->getCancelDeadline()); } - /** - * @test - */ + #[Test] public function getEnablePaymentReturnsDefaultValue(): void { self::assertFalse($this->subject->getEnablePayment()); } - /** - * @test - */ + #[Test] public function setEnablePaymentSetsEnablePaymentForBoolean(): void { $this->subject->setEnablePayment(true); self::assertTrue($this->subject->getEnablePayment()); } - /** - * @test - */ + #[Test] public function getRestrictPaymentMethodsReturnsDefaultValue(): void { self::assertFalse($this->subject->getRestrictPaymentMethods()); } - /** - * @test - */ + #[Test] public function setRestrictPaymentMethodsSetsRestrictPaymentMethodsForBoolean(): void { $this->subject->setRestrictPaymentMethods(true); self::assertTrue($this->subject->getRestrictPaymentMethods()); } - /** - * @test - */ + #[Test] public function getSelectedPaymentMethodsReturnsDefaultValue(): void { self::assertEmpty($this->subject->getSelectedPaymentMethods()); } - /** - * @test - */ + #[Test] public function setSelectedPaymentMethodsSetsSelectedPaymentMethodforString(): void { $this->subject->setSelectedPaymentMethods('invoice,transfer'); self::assertEquals('invoice,transfer', $this->subject->getSelectedPaymentMethods()); } - /** - * @test - */ + #[Test] public function getPriceOptionsReturnsInitialValueforObjectStorage(): void { $newObjectStorage = new ObjectStorage(); @@ -1183,9 +997,7 @@ public function getPriceOptionsReturnsInitialValueforObjectStorage(): void ); } - /** - * @test - */ + #[Test] public function setPriceOptionSetsPriceOptionForPriceOption(): void { $priceOption = new PriceOption(); @@ -1196,9 +1008,7 @@ public function setPriceOptionSetsPriceOptionForPriceOption(): void self::assertEquals($objectStorage, $this->subject->getPriceOptions()); } - /** - * @test - */ + #[Test] public function addPriceOptionAddsPriceOptionForPriceOption(): void { $object = new PriceOption(); @@ -1211,9 +1021,7 @@ public function addPriceOptionAddsPriceOptionForPriceOption(): void self::assertEquals($objectStorage, $this->subject->getPriceOptions()); } - /** - * @test - */ + #[Test] public function removePriceOptionRemovesPriceOptionForPriceOption(): void { $object = new PriceOption(); @@ -1226,9 +1034,7 @@ public function removePriceOptionRemovesPriceOptionForPriceOption(): void self::assertEmpty($this->subject->getPriceOptions()); } - /** - * @test - */ + #[Test] public function getActivePriceOptionsReturnsOnlyActivePriceOptions(): void { $dateYesterday = new DateTime('yesterday'); @@ -1258,18 +1064,14 @@ public function getActivePriceOptionsReturnsOnlyActivePriceOptions(): void self::assertEquals($expected, $this->subject->getActivePriceOptions()); } - /** - * @test - */ + #[Test] public function getCurrentPriceReturnsPriceIfNoPriceOptionsSet(): void { $this->subject->setPrice(12.99); self::assertEquals(12.99, $this->subject->getCurrentPrice()); } - /** - * @test - */ + #[Test] public function getCurrentPriceReturnsPriceOptionIfSet(): void { $this->subject->setPrice(19.99); @@ -1288,9 +1090,7 @@ public function getCurrentPriceReturnsPriceOptionIfSet(): void self::assertEquals(14.99, $this->subject->getCurrentPrice()); } - /** - * @test - */ + #[Test] public function getRelatedReturnsInitialValueForObjectStorage(): void { $newObjectStorage = new ObjectStorage(); @@ -1300,9 +1100,7 @@ public function getRelatedReturnsInitialValueForObjectStorage(): void ); } - /** - * @test - */ + #[Test] public function setRelatedSetsRelatedForRelated(): void { $object = new Event(); @@ -1313,9 +1111,7 @@ public function setRelatedSetsRelatedForRelated(): void self::assertEquals($objectStorage, $this->subject->getRelated()); } - /** - * @test - */ + #[Test] public function addRelatedAddsRelatedForRelated(): void { $object = new Event(); @@ -1328,9 +1124,7 @@ public function addRelatedAddsRelatedForRelated(): void self::assertEquals($objectStorage, $this->subject->getRelated()); } - /** - * @test - */ + #[Test] public function removeRelatedRemovesRelatedForRelated(): void { $object = new Event(); @@ -1378,10 +1172,8 @@ public static function cancellationPossibleDataProvider(): array ]; } - /** - * @test - * @dataProvider cancellationPossibleDataProvider - */ + #[DataProvider('cancellationPossibleDataProvider')] + #[Test] public function getCancellationPossibleReturnsExpectedValues( bool $enabled, DateTime $eventDate, @@ -1394,9 +1186,7 @@ public function getCancellationPossibleReturnsExpectedValues( self::assertEquals($expected, $this->subject->getCancellationPossible()); } - /** - * @test - */ + #[Test] public function getCancellationPossibleReturnsTrueIfNoDeadlineSet(): void { $this->subject->setStartdate(new DateTime('tomorrow')); @@ -1404,9 +1194,7 @@ public function getCancellationPossibleReturnsTrueIfNoDeadlineSet(): void self::assertTrue($this->subject->getCancellationPossible()); } - /** - * @test - */ + #[Test] public function getCancellationPossibleReturnsFalseIfNoDeadlineSetButEventExpired(): void { $this->subject->setStartdate(new DateTime('yesterday')); @@ -1414,26 +1202,20 @@ public function getCancellationPossibleReturnsFalseIfNoDeadlineSetButEventExpire self::assertFalse($this->subject->getCancellationPossible()); } - /** - * @test - */ + #[Test] public function enableAutoconfirmReturnsDefaultValue(): void { self::assertFalse($this->subject->getEnableAutoconfirm()); } - /** - * @test - */ + #[Test] public function setEnableAutoconfirmSetsAutoconfirmForBoolean(): void { $this->subject->setEnableAutoconfirm(true); self::assertTrue($this->subject->getEnableAutoconfirm()); } - /** - * @test - */ + #[Test] public function getSpeakerReturnsInitialValueforObjectStorage(): void { $newObjectStorage = new ObjectStorage(); @@ -1443,9 +1225,7 @@ public function getSpeakerReturnsInitialValueforObjectStorage(): void ); } - /** - * @test - */ + #[Test] public function setSpeakerSetsSpeaker(): void { $speaker = new Speaker(); @@ -1455,9 +1235,7 @@ public function setSpeakerSetsSpeaker(): void self::assertEquals($objectStorageWithSpeaker, $this->subject->getSpeaker()); } - /** - * @test - */ + #[Test] public function addSpeakerAddsSpeaker(): void { $object = new Speaker(); @@ -1470,9 +1248,7 @@ public function addSpeakerAddsSpeaker(): void self::assertEquals($objectStorage, $this->subject->getSpeaker()); } - /** - * @test - */ + #[Test] public function removeSpeakerRemovesSpeaker(): void { $object = new Speaker(); @@ -1485,9 +1261,7 @@ public function removeSpeakerRemovesSpeaker(): void $this->assertempty($this->subject->getSpeaker()); } - /** - * @test - */ + #[Test] public function getRegistrationFieldsReturnsInitialValueforObjectStorage(): void { $newObjectStorage = new ObjectStorage(); @@ -1497,9 +1271,7 @@ public function getRegistrationFieldsReturnsInitialValueforObjectStorage(): void ); } - /** - * @test - */ + #[Test] public function setRegistrationFieldsSetsRegistrationFields(): void { $registrationField = new Field(); @@ -1509,9 +1281,7 @@ public function setRegistrationFieldsSetsRegistrationFields(): void self::assertEquals($objectStorageWithRegistrationField, $this->subject->getRegistrationFields()); } - /** - * @test - */ + #[Test] public function addRegistrationFieldsAddsRegistrationField(): void { $object = new Field(); @@ -1524,9 +1294,7 @@ public function addRegistrationFieldsAddsRegistrationField(): void self::assertEquals($objectStorage, $this->subject->getRegistrationFields()); } - /** - * @test - */ + #[Test] public function removeRegistrationFieldsRemovesRegistrationField(): void { $object = new Field(); @@ -1539,43 +1307,35 @@ public function removeRegistrationFieldsRemovesRegistrationField(): void self::assertEmpty($this->subject->getRegistrationFields()); } - /** - * @test - */ + #[Test] public function getRegistrationFieldsUidsReturnsEmptyArrayIfNotRegistrationFields(): void { self::assertEquals([], $this->subject->getRegistrationFieldsUids()); } - /** - * @test - */ + #[Test] public function getRegistrationFieldsUidsReturnsExpectedArrayForEventWithRegistrationFields(): void { - $mockRegField = $this->getMockBuilder(Registration\Field::class)->getMock(); + $mockRegField = $this->getMockBuilder(Field::class)->getMock(); $mockRegField->expects(self::any())->method('getUid')->willReturn(1); $this->subject->addRegistrationFields($mockRegField); self::assertEquals([0 => 1], $this->subject->getRegistrationFieldsUids()); } - /** - * @test - */ + #[Test] public function getRegistrationFieldUidsWithTitleReturnsEmptyArrayIfNotRegistrationFields(): void { self::assertEquals([], $this->subject->getRegistrationFieldUidsWithTitle()); } - /** - * @test - */ + #[Test] public function getRegistrationFieldUidsWithTitleReturnsExpectedArrayForEventWithRegistrationFields(): void { - $mockRegField1 = $this->getMockBuilder(Registration\Field::class)->getMock(); + $mockRegField1 = $this->getMockBuilder(Field::class)->getMock(); $mockRegField1->expects(self::any())->method('getUid')->willReturn(1); $mockRegField1->expects(self::any())->method('getTitle')->willReturn('A Title'); - $mockRegField2 = $this->getMockBuilder(Registration\Field::class)->getMock(); + $mockRegField2 = $this->getMockBuilder(Field::class)->getMock(); $mockRegField2->expects(self::any())->method('getUid')->willReturn(2); $mockRegField2->expects(self::any())->method('getTitle')->willReturn('Another Title'); $this->subject->addRegistrationFields($mockRegField1); @@ -1619,10 +1379,8 @@ public static function eventEndsSameDayDataProvider(): array ]; } - /** - * @test - * @dataProvider eventEndsSameDayDataProvider - */ + #[DataProvider('eventEndsSameDayDataProvider')] + #[Test] public function eventEndsSameDayReturnsExpectedValue(?DateTime $startdate, ?DateTime $enddate, bool $expected): void { if ($startdate) { @@ -1634,34 +1392,26 @@ public function eventEndsSameDayReturnsExpectedValue(?DateTime $startdate, ?Date self::assertEquals($expected, $this->subject->getEndsSameDay()); } - /** - * @test - */ + #[Test] public function getHiddenReturnsInitialValue(): void { self::assertFalse($this->subject->getHidden()); } - /** - * @test - */ + #[Test] public function setHiddenSetsValueForBoolean(): void { $this->subject->setHidden(true); self::assertTrue($this->subject->getHidden()); } - /** - * @test - */ + #[Test] public function getStarttimeReturnsInitialValue(): void { self::assertNull($this->subject->getStarttime()); } - /** - * @test - */ + #[Test] public function setStarttimeSetsValueForDateTime(): void { $date = new DateTime('01.01.2020 18:00:00'); @@ -1670,17 +1420,13 @@ public function setStarttimeSetsValueForDateTime(): void self::assertEquals($date, $this->subject->getStarttime()); } - /** - * @test - */ + #[Test] public function getEndtimeReturnsInitialValue(): void { self::assertNull($this->subject->getEndtime()); } - /** - * @test - */ + #[Test] public function setEndtimeSetsValueForDateTime(): void { $date = new DateTime('01.01.2020 18:00:00'); @@ -1689,62 +1435,48 @@ public function setEndtimeSetsValueForDateTime(): void self::assertEquals($date, $this->subject->getEndtime()); } - /** - * @test - */ + #[Test] public function getBackendIconOverlayReturnsEmptyStringIfNotHiddenAndNoStartEndTime(): void { self::assertEquals('', $this->subject->getBackendIconOverlay()); } - /** - * @test - */ + #[Test] public function getBackendIconOverlayReturnsExpectedValueForHiddenEvent(): void { $this->subject->setHidden(true); self::assertEquals('overlay-hidden', $this->subject->getBackendIconOverlay()); } - /** - * @test - */ + #[Test] public function getBackendIconOverlayReturnsExpectedValueForNotStartedStarttimeEvent(): void { $this->subject->setStarttime((new DateTime())->modify('+1 day')); self::assertEquals('overlay-scheduled', $this->subject->getBackendIconOverlay()); } - /** - * @test - */ + #[Test] public function getBackendIconOverlayReturnsExpectedValueForStartedStarttimeEvent(): void { $this->subject->setStarttime((new DateTime())->modify('-1 day')); self::assertEquals('', $this->subject->getBackendIconOverlay()); } - /** - * @test - */ + #[Test] public function getBackendIconOverlayReturnsExpectedValueForEndedEndtimeEvent(): void { $this->subject->setEndtime((new DateTime())->modify('-1 day')); self::assertEquals('overlay-endtime', $this->subject->getBackendIconOverlay()); } - /** - * @test - */ + #[Test] public function getBackendIconOverlayReturnsExpectedValueForNotEndedEndtimeEvent(): void { $this->subject->setEndtime((new DateTime())->modify('+1 day')); self::assertEquals('overlay-scheduled', $this->subject->getBackendIconOverlay()); } - /** - * @test - */ + #[Test] public function getBackendIconOverlayReturnsExpectedValueForHiddenAndStarttimeEvent(): void { $this->subject->setHidden(true); @@ -1752,9 +1484,7 @@ public function getBackendIconOverlayReturnsExpectedValueForHiddenAndStarttimeEv self::assertEquals('overlay-hidden', $this->subject->getBackendIconOverlay()); } - /** - * @test - */ + #[Test] public function getImagesReturnsValueOfImage(): void { $image = new FileReference(); @@ -1764,60 +1494,46 @@ public function getImagesReturnsValueOfImage(): void self::assertEquals($objectStorageHoldingExactlyOneImage, $this->subject->getImages()); } - /** - * @test - */ + #[Test] public function getMetaKeywordsReturnsInitialValue(): void { self::assertEquals('', $this->subject->getMetaKeywords()); } - /** - * @test - */ + #[Test] public function setMetaKeywordsSetsKeywords(): void { $this->subject->setMetaKeywords('keyword1, keyword2'); self::assertEquals('keyword1, keyword2', $this->subject->getMetaKeywords()); } - /** - * @test - */ + #[Test] public function getMetaDescriptionReturnsInitialValue(): void { self::assertEquals('', $this->subject->getMetaDescription()); } - /** - * @test - */ + #[Test] public function setMetaDescriptionSetsDescription(): void { $this->subject->setMetaDescription('the description'); self::assertEquals('the description', $this->subject->getMetaDescription()); } - /** - * @test - */ + #[Test] public function getAlternativeTitleReturnsInitialValue(): void { self::assertEquals('', $this->subject->getAlternativeTitle()); } - /** - * @test - */ + #[Test] public function setAlternativetitleSetsAlternativeTitle(): void { $this->subject->setAlternativeTitle('the alternative title'); self::assertEquals('the alternative title', $this->subject->getAlternativeTitle()); } - /** - * @test - */ + #[Test] public function getMetaTitleReturnsTitleWhenNoAlternativeTitle(): void { $this->subject->setTitle('the title'); @@ -1825,9 +1541,7 @@ public function getMetaTitleReturnsTitleWhenNoAlternativeTitle(): void self::assertEquals('the title', $this->subject->getMetaTitle()); } - /** - * @test - */ + #[Test] public function getMetaTitleReturnsAlternativeTitleWhenNoAlternativeTitle(): void { $this->subject->setTitle('the title'); @@ -1836,9 +1550,7 @@ public function getMetaTitleReturnsAlternativeTitleWhenNoAlternativeTitle(): voi self::assertEquals('the alternative title', $this->subject->getMetaTitle()); } - /** - * @test - */ + #[Test] public function specialGettersForImagesReturnsExpectedResults(): void { $file1 = $this->getMockBuilder(File::class)->disableOriginalConstructor()->getMock(); diff --git a/Tests/Unit/Domain/Model/FrontendUserTest.php b/Tests/Unit/Domain/Model/FrontendUserTest.php index 8a6878a95..24f606dc1 100644 --- a/Tests/Unit/Domain/Model/FrontendUserTest.php +++ b/Tests/Unit/Domain/Model/FrontendUserTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Domain\Model; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\FrontendUser; use TYPO3\CMS\Extbase\Persistence\ObjectStorage; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -29,272 +30,208 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function getUsernameReturnsInitialValue(): void { self::assertEquals('', $this->subject->getUsername()); } - /** - * @test - */ + #[Test] public function setUsernameSetsUsername(): void { $this->subject->setUsername('typo3'); self::assertEquals('typo3', $this->subject->getUsername()); } - /** - * @test - */ + #[Test] public function getNameReturnsInitialValue(): void { self::assertEquals('', $this->subject->getName()); } - /** - * @test - */ + #[Test] public function setNameSetsName(): void { $this->subject->setName('Random Name'); self::assertEquals('Random Name', $this->subject->getName()); } - /** - * @test - */ + #[Test] public function getFirstNameReturnsInitialValue(): void { self::assertEquals('', $this->subject->getFirstName()); } - /** - * @test - */ + #[Test] public function setFirstNameSetsFirstName(): void { $this->subject->setFirstName('Firstname'); self::assertEquals('Firstname', $this->subject->getFirstName()); } - /** - * @test - */ + #[Test] public function getMiddleNameReturnsInitialValue(): void { self::assertEquals('', $this->subject->getMiddleName()); } - /** - * @test - */ + #[Test] public function setMiddleNameSetsMiddleName(): void { $this->subject->setMiddleName('Middlename'); self::assertEquals('Middlename', $this->subject->getMiddleName()); } - /** - * @test - */ + #[Test] public function getLastNameReturnsInitialValue(): void { self::assertEquals('', $this->subject->getLastName()); } - /** - * @test - */ + #[Test] public function setLastNameSetsLastName(): void { $this->subject->setLastName('Lastname'); self::assertEquals('Lastname', $this->subject->getLastName()); } - /** - * @test - */ + #[Test] public function getAddressReturnsInitialValue(): void { self::assertEquals('', $this->subject->getAddress()); } - /** - * @test - */ + #[Test] public function setAddressSetsAddress(): void { $this->subject->setAddress('Address'); self::assertEquals('Address', $this->subject->getAddress()); } - /** - * @test - */ + #[Test] public function getTelephoneReturnsInitialValue(): void { self::assertEquals('', $this->subject->getTelephone()); } - /** - * @test - */ + #[Test] public function setTelephoneSetsTelephone(): void { $this->subject->setTelephone('Telephone'); self::assertEquals('Telephone', $this->subject->getTelephone()); } - /** - * @test - */ + #[Test] public function getFaxReturnsInitialValue(): void { self::assertEquals('', $this->subject->getFax()); } - /** - * @test - */ + #[Test] public function setFaxSetsFax(): void { $this->subject->setFax('Fax'); self::assertEquals('Fax', $this->subject->getFax()); } - /** - * @test - */ + #[Test] public function getEmailReturnsInitialValue(): void { self::assertEquals('', $this->subject->getEmail()); } - /** - * @test - */ + #[Test] public function setEmailSetsEmail(): void { $this->subject->setEmail('email'); self::assertEquals('email', $this->subject->getEmail()); } - /** - * @test - */ + #[Test] public function getTitleReturnsInitialValue(): void { self::assertEquals('', $this->subject->getTitle()); } - /** - * @test - */ + #[Test] public function setTitleSetsTitle(): void { $this->subject->setTitle('title'); self::assertEquals('title', $this->subject->getTitle()); } - /** - * @test - */ + #[Test] public function getZipReturnsInitialValue(): void { self::assertEquals('', $this->subject->getZip()); } - /** - * @test - */ + #[Test] public function setZipSetsZip(): void { $this->subject->setZip('12345'); self::assertEquals('12345', $this->subject->getZip()); } - /** - * @test - */ + #[Test] public function getCityReturnsInitialValue(): void { self::assertEquals('', $this->subject->getCity()); } - /** - * @test - */ + #[Test] public function setCitySetsCity(): void { $this->subject->setCity('city'); self::assertEquals('city', $this->subject->getCity()); } - /** - * @test - */ + #[Test] public function getCountryReturnsInitialValue(): void { self::assertEquals('', $this->subject->getCountry()); } - /** - * @test - */ + #[Test] public function setCountrySetsCountry(): void { $this->subject->setCountry('country'); self::assertEquals('country', $this->subject->getCountry()); } - /** - * @test - */ + #[Test] public function getWwwReturnsInitialValue(): void { self::assertEquals('', $this->subject->getWww()); } - /** - * @test - */ + #[Test] public function setWwwSetsWww(): void { $this->subject->setWww('typo3.org'); self::assertEquals('typo3.org', $this->subject->getWww()); } - /** - * @test - */ + #[Test] public function getCompanyReturnsInitialValue(): void { self::assertEquals('', $this->subject->getCompany()); } - /** - * @test - */ + #[Test] public function setCompanySetsCompany(): void { $this->subject->setCompany('company'); self::assertEquals('company', $this->subject->getCompany()); } - /** - * @test - */ + #[Test] public function getImageReturnsInitialValue(): void { self::assertEquals(new ObjectStorage(), $this->subject->getImage()); } - /** - * @test - */ + #[Test] public function setImageSetsImage(): void { $image = new ObjectStorage(); diff --git a/Tests/Unit/Domain/Model/LocationTest.php b/Tests/Unit/Domain/Model/LocationTest.php index 8a073452f..bb3564647 100644 --- a/Tests/Unit/Domain/Model/LocationTest.php +++ b/Tests/Unit/Domain/Model/LocationTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Domain\Model; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; use DERHANSEN\SfEventMgt\Domain\Model\Location; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -30,9 +32,8 @@ protected function tearDown(): void /** * Test if initial value for title is returned - * - * @test */ + #[Test] public function getTitleReturnsInitialValueForString(): void { self::assertSame( @@ -43,18 +44,15 @@ public function getTitleReturnsInitialValueForString(): void /** * Test if title can be set - * - * @test */ + #[Test] public function setTitleForStringSetsTitle(): void { $this->subject->setTitle('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->getTitle()); } - /** - * @test - */ + #[Test] public function getAddressReturnsInitialValueForString(): void { self::assertSame( @@ -63,18 +61,14 @@ public function getAddressReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setAddressForStringSetsAddress(): void { $this->subject->setAddress('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->getAddress()); } - /** - * @test - */ + #[Test] public function getZipReturnsInitialValueForInteger(): void { self::assertSame( @@ -83,18 +77,14 @@ public function getZipReturnsInitialValueForInteger(): void ); } - /** - * @test - */ + #[Test] public function setZipForIntegerSetsZip(): void { $this->subject->setZip('12'); self::assertSame('12', $this->subject->getZip()); } - /** - * @test - */ + #[Test] public function getCityReturnsInitialValueForString(): void { self::assertSame( @@ -103,9 +93,7 @@ public function getCityReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function getCountryReturnsInitialValueForString(): void { self::assertSame( @@ -114,18 +102,14 @@ public function getCountryReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setCityForStringSetsCity(): void { $this->subject->setCity('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->getCity()); } - /** - * @test - */ + #[Test] public function setCountryForStringSetsCountry(): void { $this->subject->setCountry('A country'); @@ -134,9 +118,8 @@ public function setCountryForStringSetsCountry(): void /** * Test if description returns initial value - * - * @test */ + #[Test] public function getDescriptionReturnsInitialValueForString(): void { self::assertSame( @@ -147,9 +130,8 @@ public function getDescriptionReturnsInitialValueForString(): void /** * Test if description can be set - * - * @test */ + #[Test] public function setDescriptionForStringSetsDescription(): void { $this->subject->setDescription('Conceived at T3CON10'); @@ -158,9 +140,8 @@ public function setDescriptionForStringSetsDescription(): void /** * Test if link returns initial value - * - * @test */ + #[Test] public function getLinkReturnsInitialValueForString(): void { self::assertSame( @@ -171,9 +152,8 @@ public function getLinkReturnsInitialValueForString(): void /** * Test if link can be set - * - * @test */ + #[Test] public function setLinkForStringSetsLink(): void { $this->subject->setLink('http://www.typo3.org'); @@ -182,9 +162,8 @@ public function setLinkForStringSetsLink(): void /** * Test if initial value is returned - * - * @test */ + #[Test] public function getLongitudeReturnsInitialValueForFloat(): void { self::assertSame(0.0, $this->subject->getLongitude()); @@ -192,9 +171,8 @@ public function getLongitudeReturnsInitialValueForFloat(): void /** * Test if longitude can be set - * - * @test */ + #[Test] public function setLongitudeSetsLongitude(): void { $this->subject->setLongitude(12.345678); @@ -203,9 +181,8 @@ public function setLongitudeSetsLongitude(): void /** * Test if initial value is returned - * - * @test */ + #[Test] public function getLatitudeReturnsInitialValueForFloat(): void { self::assertSame(0.0, $this->subject->getLatitude()); @@ -213,9 +190,8 @@ public function getLatitudeReturnsInitialValueForFloat(): void /** * Test if latitude can be set - * - * @test */ + #[Test] public function setLatitudeSetsLatitude(): void { $this->subject->setLatitude(12.345678); @@ -275,10 +251,8 @@ public static function getFullAddressReturnsExpectedResultDataProvider(): array ]; } - /** - * @test - * @dataProvider getFullAddressReturnsExpectedResultDataProvider - */ + #[DataProvider('getFullAddressReturnsExpectedResultDataProvider')] + #[Test] public function getFullAddressReturnsExpectedResult($location, $separator, $expected): void { /** @var Location $location */ diff --git a/Tests/Unit/Domain/Model/OrganisatorTest.php b/Tests/Unit/Domain/Model/OrganisatorTest.php index 1214936c6..94ca7018f 100644 --- a/Tests/Unit/Domain/Model/OrganisatorTest.php +++ b/Tests/Unit/Domain/Model/OrganisatorTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Domain\Model; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Organisator; use TYPO3\CMS\Extbase\Domain\Model\FileReference; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -31,9 +32,8 @@ protected function tearDown(): void /** * Test if initial value for name is returned - * - * @test */ + #[Test] public function getNameReturnsInitialValueForString(): void { self::assertSame( @@ -44,9 +44,8 @@ public function getNameReturnsInitialValueForString(): void /** * Test if name can be set - * - * @test */ + #[Test] public function setNameForStringSetsName(): void { $this->subject->setName('Conceived at T3CON10'); @@ -55,9 +54,8 @@ public function setNameForStringSetsName(): void /** * Test if initial value for email is returned - * - * @test */ + #[Test] public function getEmailReturnsInitialValueForString(): void { self::assertSame( @@ -68,9 +66,8 @@ public function getEmailReturnsInitialValueForString(): void /** * Test if email can be set - * - * @test */ + #[Test] public function setEmailForStringSetsEmail(): void { $this->subject->setEmail('mail@domain.tld'); @@ -79,9 +76,8 @@ public function setEmailForStringSetsEmail(): void /** * Test if initial value for phone is returned - * - * @test */ + #[Test] public function getPhoneReturnsInitialValueForString(): void { self::assertSame( @@ -92,9 +88,8 @@ public function getPhoneReturnsInitialValueForString(): void /** * Test if phone can be set - * - * @test */ + #[Test] public function setPhoneForStringSetsPhone(): void { $this->subject->setPhone('+49 123 4567890'); @@ -103,9 +98,8 @@ public function setPhoneForStringSetsPhone(): void /** * Test if initial value for link is returned - * - * @test */ + #[Test] public function getLinkReturnsInitialValueForString(): void { self::assertSame( @@ -116,9 +110,8 @@ public function getLinkReturnsInitialValueForString(): void /** * Test if link can be set - * - * @test */ + #[Test] public function setLinkForStringSetsLink(): void { $this->subject->setLink('https://www.derhansen.com'); @@ -127,9 +120,8 @@ public function setLinkForStringSetsLink(): void /** * Test if initial value for image is returned - * - * @test */ + #[Test] public function getImageReturnsInitialValueForfiles(): void { self::assertNull($this->subject->getImage()); @@ -137,9 +129,8 @@ public function getImageReturnsInitialValueForfiles(): void /** * Test if image can be set - * - * @test */ + #[Test] public function setImageForObjectStorageContainingImageSetsImage(): void { $file = new FileReference(); diff --git a/Tests/Unit/Domain/Model/PriceOptionTest.php b/Tests/Unit/Domain/Model/PriceOptionTest.php index 784cece7f..6f9c14ceb 100644 --- a/Tests/Unit/Domain/Model/PriceOptionTest.php +++ b/Tests/Unit/Domain/Model/PriceOptionTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Domain\Model; +use PHPUnit\Framework\Attributes\Test; use DateTime; use DERHANSEN\SfEventMgt\Domain\Model\Event; use DERHANSEN\SfEventMgt\Domain\Model\PriceOption; @@ -32,9 +33,8 @@ protected function tearDown(): void /** * Test if initial value for price is returned - * - * @test */ + #[Test] public function getPriceReturnsInitialValueForFloat(): void { self::assertSame( @@ -45,9 +45,8 @@ public function getPriceReturnsInitialValueForFloat(): void /** * Test if price can be set - * - * @test */ + #[Test] public function setPriceForFloatSetsPrice(): void { $this->subject->setPrice(12.99); @@ -56,9 +55,8 @@ public function setPriceForFloatSetsPrice(): void /** * Test if validUntil date returns intitial value - * - * @test */ + #[Test] public function getValidUntilReturnsInitialValueForDate(): void { self::assertNull($this->subject->getValidUntil()); @@ -66,9 +64,8 @@ public function getValidUntilReturnsInitialValueForDate(): void /** * Test if validUntil date can be set - * - * @test */ + #[Test] public function setValidUntilForDateSetsValidUntil(): void { $date = new DateTime('01.01.2016'); @@ -76,17 +73,13 @@ public function setValidUntilForDateSetsValidUntil(): void self::assertEquals($date, $this->subject->getValidUntil()); } - /** - * @test - */ + #[Test] public function getEventReturnsInitialValue(): void { self::assertNull($this->subject->getEvent()); } - /** - * @test - */ + #[Test] public function setEventForEventSetsEvent(): void { $event = new Event(); diff --git a/Tests/Unit/Domain/Model/Registration/FieldTest.php b/Tests/Unit/Domain/Model/Registration/FieldTest.php index 35bb6ec02..6c6f61b1a 100644 --- a/Tests/Unit/Domain/Model/Registration/FieldTest.php +++ b/Tests/Unit/Domain/Model/Registration/FieldTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Domain\Model\Registration; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; use DERHANSEN\SfEventMgt\Domain\Model\Event; use DERHANSEN\SfEventMgt\Domain\Model\Registration\Field; use DERHANSEN\SfEventMgt\Utility\FieldType; @@ -31,119 +33,91 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function getTitleReturnsInitialValueForString(): void { self::assertEquals('', $this->subject->getTitle()); } - /** - * @test - */ + #[Test] public function setTitleSetsTitleField(): void { $this->subject->setTitle('A title'); self::assertEquals('A title', $this->subject->getTitle()); } - /** - * @test - */ + #[Test] public function getTypeReturnsInitialValueForString(): void { self::assertEquals('', $this->subject->getType()); } - /** - * @test - */ + #[Test] public function setTypeSetsTypefield(): void { $this->subject->setType('check'); self::assertEquals('check', $this->subject->getType()); } - /** - * @test - */ + #[Test] public function getRequiredReturnsInitialValueForBoolean(): void { self::assertFalse($this->subject->getRequired()); } - /** - * @test - */ + #[Test] public function setRequiredSetsRequiredField(): void { $this->subject->setRequired(true); self::assertTrue($this->subject->getRequired()); } - /** - * @test - */ + #[Test] public function getPlaceholderReturnsInitialValueForString(): void { self::assertEquals('', $this->subject->getPlaceholder()); } - /** - * @test - */ + #[Test] public function setPlaceholderSetsPlaceholderField(): void { $this->subject->setPlaceholder('placeholder'); self::assertEquals('placeholder', $this->subject->getPlaceholder()); } - /** - * @test - */ + #[Test] public function getDefaultValueReturnsInitialValueForString(): void { self::assertEquals('', $this->subject->getDefaultValue()); } - /** - * @test - */ + #[Test] public function setDefaultValueSetsDefaultValueField(): void { $this->subject->setDefaultValue('default'); self::assertEquals('default', $this->subject->getDefaultValue()); } - /** - * @test - */ + #[Test] public function getSettingsReturnsInitialValueForString(): void { self::assertEquals('', $this->subject->getSettings()); } - /** - * @test - */ + #[Test] public function setSettingsSetsSettingsField(): void { $this->subject->setSettings('settings'); self::assertEquals('settings', $this->subject->getSettings()); } - /** - * @test - */ + #[Test] public function getEventReturnsInitialValueForEvent(): void { self::assertNull($this->subject->getEvent()); } - /** - * @test - */ + #[Test] public function setEventSetsEventField(): void { $event = new Event(); @@ -221,10 +195,8 @@ public static function getSettingsForOptionDataProvider(): array ]; } - /** - * @test - * @dataProvider getSettingsForOptionDataProvider - */ + #[DataProvider('getSettingsForOptionDataProvider')] + #[Test] public function getSettingsForOptionReturnsExpectedValues(string $settings, string $defaultValue, array $expected): void { $this->subject->setSettings($settings); @@ -232,9 +204,7 @@ public function getSettingsForOptionReturnsExpectedValues(string $settings, stri self::assertSame($expected, $this->subject->getSettingsForOption()); } - /** - * @test - */ + #[Test] public function getValueTypeReturnsInitialValue(): void { self::assertEquals(FieldValueType::TYPE_TEXT, $this->subject->getValueType()); @@ -278,19 +248,15 @@ public static function getValueTypeReturnsExpectedFieldValuesDataProvider(): arr ]; } - /** - * @test - * @dataProvider getValueTypeReturnsExpectedFieldValuesDataProvider - */ + #[DataProvider('getValueTypeReturnsExpectedFieldValuesDataProvider')] + #[Test] public function getValueTypeReturnsExpectedFieldValues(string $fieldType, int $expected): void { $this->subject->setType($fieldType); self::assertEquals($expected, $this->subject->getValueType()); } - /** - * @test - */ + #[Test] public function getPartialNameReturnsFieldTypeInUppercase(): void { $this->subject->setType('input'); @@ -315,61 +281,47 @@ public static function getDatepickermodeTypeDataProvider(): array ]; } - /** - * @test - * @dataProvider getDatepickermodeTypeDataProvider - */ + #[DataProvider('getDatepickermodeTypeDataProvider')] + #[Test] public function getDatepickermodeTypeReturnsExpectedValue(int $datepickerMode, string $expected): void { $this->subject->setDatepickermode($datepickerMode); self::assertEquals($expected, $this->subject->getDatepickermodeType()); } - /** - * @test - */ + #[Test] public function getTextReturnsInitialValue(): void { self::assertEmpty($this->subject->getText()); } - /** - * @test - */ + #[Test] public function setTextSetsTextForString(): void { $this->subject->setText('TYPO3'); self::assertEquals('TYPO3', $this->subject->getText()); } - /** - * @test - */ + #[Test] public function getDatepickermodeReturnsInitialValue(): void { self::assertEquals(0, $this->subject->getDatepickermode()); } - /** - * @test - */ + #[Test] public function setDatepickermodeSetsValueForInt(): void { $this->subject->setDatepickermode(2); self::assertEquals(2, $this->subject->getDatepickermode()); } - /** - * @test - */ + #[Test] public function getFeuserValueReturnInitialValue(): void { self::assertEquals('', $this->subject->getFeuserValue()); } - /** - * @test - */ + #[Test] public function setFeuserValueSetsValueForString(): void { $expected = 'John'; diff --git a/Tests/Unit/Domain/Model/Registration/FieldValueTest.php b/Tests/Unit/Domain/Model/Registration/FieldValueTest.php index f8981c749..9e94f4df9 100644 --- a/Tests/Unit/Domain/Model/Registration/FieldValueTest.php +++ b/Tests/Unit/Domain/Model/Registration/FieldValueTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Domain\Model\Registration; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Registration; use DERHANSEN\SfEventMgt\Domain\Model\Registration\Field; use DERHANSEN\SfEventMgt\Domain\Model\Registration\FieldValue; @@ -31,9 +32,7 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function getValueReturnsInitialValueForString(): void { $mockField = $this->getMockBuilder(Field::class)->onlyMethods(['getValueType'])->getMock(); @@ -42,18 +41,14 @@ public function getValueReturnsInitialValueForString(): void self::assertEquals('', $this->subject->getValue()); } - /** - * @test - */ + #[Test] public function setValueSetsValueField(): void { $this->subject->setValue('A field value'); self::assertEquals('A field value', $this->subject->getValue()); } - /** - * @test - */ + #[Test] public function getValueReturnsArrayForFieldTypeArray(): void { $expectedArray = ['value1', 'value2']; @@ -65,9 +60,7 @@ public function getValueReturnsArrayForFieldTypeArray(): void self::assertSame($expectedArray, $this->subject->getValue()); } - /** - * @test - */ + #[Test] public function getValueReturnsArrayForFieldTypeArrayAndValueString(): void { $expectedArray = ['value1']; @@ -79,17 +72,13 @@ public function getValueReturnsArrayForFieldTypeArrayAndValueString(): void self::assertSame($expectedArray, $this->subject->getValue()); } - /** - * @test - */ + #[Test] public function getFieldReturnsInitialValueForField(): void { self::assertNull($this->subject->getField()); } - /** - * @test - */ + #[Test] public function setFieldSetsField(): void { $field = new Field(); @@ -97,17 +86,13 @@ public function setFieldSetsField(): void self::assertEquals($field, $this->subject->getField()); } - /** - * @test - */ + #[Test] public function getRegistrationReturnsInitialValueForRegistration(): void { self::assertNull($this->subject->getRegistration()); } - /** - * @test - */ + #[Test] public function setRegistrationSetsRegistration(): void { $registration = new Registration(); @@ -115,26 +100,20 @@ public function setRegistrationSetsRegistration(): void self::assertEquals($registration, $this->subject->getRegistration()); } - /** - * @test - */ + #[Test] public function getValueTypeReturnsInitialValueForValueType(): void { self::assertEquals(FieldValueType::TYPE_TEXT, $this->subject->getValueType()); } - /** - * @test - */ + #[Test] public function setValueTypeSetsValueType(): void { $this->subject->setValueType(FieldValueType::TYPE_ARRAY); self::assertEquals(FieldValueType::TYPE_ARRAY, $this->subject->getValueType()); } - /** - * @test - */ + #[Test] public function getValueForCsvExportReturnsArrayAsCommaSeparatedStringForArrayValues(): void { $expectedArray = 'value1,value2'; @@ -146,18 +125,14 @@ public function getValueForCsvExportReturnsArrayAsCommaSeparatedStringForArrayVa self::assertSame($expectedArray, $this->subject->getValueForCsvExport()); } - /** - * @test - */ + #[Test] public function getValueWhenNoFieldAvailable(): void { $this->subject->setValue('Test'); self::assertSame('Test', $this->subject->getValue()); } - /** - * @test - */ + #[Test] public function getValueForCsvExportNoFieldAvailable(): void { $this->subject->setValue('Test'); diff --git a/Tests/Unit/Domain/Model/RegistrationTest.php b/Tests/Unit/Domain/Model/RegistrationTest.php index fd8d29324..409412be6 100644 --- a/Tests/Unit/Domain/Model/RegistrationTest.php +++ b/Tests/Unit/Domain/Model/RegistrationTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Domain\Model; +use PHPUnit\Framework\Attributes\Test; use DateTime; use DERHANSEN\SfEventMgt\Domain\Model\Event; use DERHANSEN\SfEventMgt\Domain\Model\FrontendUser; @@ -31,9 +32,7 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function getFirstnameReturnsInitialValueForString(): void { self::assertSame( @@ -42,18 +41,14 @@ public function getFirstnameReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setFirstnameForStringSetsFirstname(): void { $this->subject->setFirstname('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->getFirstname()); } - /** - * @test - */ + #[Test] public function getLastnameReturnsInitialValueForString(): void { self::assertSame( @@ -62,18 +57,14 @@ public function getLastnameReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setLastnameForStringSetsLastname(): void { $this->subject->setLastname('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->getLastname()); } - /** - * @test - */ + #[Test] public function getTitleReturnsInitialValueForString(): void { self::assertSame( @@ -82,18 +73,14 @@ public function getTitleReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setTitleForStringSetsTitle(): void { $this->subject->setTitle('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->getTitle()); } - /** - * @test - */ + #[Test] public function getCompanyReturnsInitialValueForString(): void { self::assertSame( @@ -102,18 +89,14 @@ public function getCompanyReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setCompanyForStringSetsCompany(): void { $this->subject->setCompany('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->getCompany()); } - /** - * @test - */ + #[Test] public function getAddressReturnsInitialValueForString(): void { self::assertSame( @@ -122,18 +105,14 @@ public function getAddressReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setAddressForStringSetsAddress(): void { $this->subject->setAddress('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->getAddress()); } - /** - * @test - */ + #[Test] public function getZipReturnsInitialValueForString(): void { self::assertSame( @@ -142,18 +121,14 @@ public function getZipReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setZipForIntegerSetsZip(): void { $this->subject->setZip('01234'); self::assertEquals('01234', $this->subject->getZip()); } - /** - * @test - */ + #[Test] public function getCityReturnsInitialValueForString(): void { self::assertSame( @@ -162,9 +137,7 @@ public function getCityReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function getCountryReturnsInitialValueForString(): void { self::assertSame( @@ -173,27 +146,21 @@ public function getCountryReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setCityForStringSetsCity(): void { $this->subject->setCity('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->getCity()); } - /** - * @test - */ + #[Test] public function setCountryForStringSetsCountry(): void { $this->subject->setCountry('A country'); self::assertEquals('A country', $this->subject->getCountry()); } - /** - * @test - */ + #[Test] public function getPhoneReturnsInitialValueForString(): void { self::assertSame( @@ -202,18 +169,14 @@ public function getPhoneReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setPhoneForStringSetsPhone(): void { $this->subject->setPhone('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->getPhone()); } - /** - * @test - */ + #[Test] public function getEmailReturnsInitialValueForString(): void { self::assertSame( @@ -222,18 +185,14 @@ public function getEmailReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setEmailForStringSetsEmail(): void { $this->subject->setEmail('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->getEmail()); } - /** - * @test - */ + #[Test] public function getGenderReturnsInitialValueForString(): void { self::assertSame( @@ -242,18 +201,14 @@ public function getGenderReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setGenderForStringSetsGender(): void { $this->subject->setGender('m'); self::assertEquals('m', $this->subject->getGender()); } - /** - * @test - */ + #[Test] public function getAccepttcReturnsInitialValueForBoolean(): void { self::assertFalse( @@ -261,18 +216,14 @@ public function getAccepttcReturnsInitialValueForBoolean(): void ); } - /** - * @test - */ + #[Test] public function setAccepttcForBooleanSetsConfirmed(): void { $this->subject->setAccepttc(true); self::assertTrue($this->subject->getAccepttc()); } - /** - * @test - */ + #[Test] public function getWaitlistReturnsInitialValueForBoolean(): void { self::assertFalse( @@ -280,18 +231,14 @@ public function getWaitlistReturnsInitialValueForBoolean(): void ); } - /** - * @test - */ + #[Test] public function setWaitlistForBooleanSetsWaitlist(): void { $this->subject->setWaitlist(true); self::assertTrue($this->subject->getWaitlist()); } - /** - * @test - */ + #[Test] public function getConfirmedReturnsInitialValueForBoolean(): void { self::assertFalse( @@ -299,27 +246,21 @@ public function getConfirmedReturnsInitialValueForBoolean(): void ); } - /** - * @test - */ + #[Test] public function setConfirmedForBooleanSetsConfirmed(): void { $this->subject->setConfirmed(true); self::assertTrue($this->subject->getConfirmed()); } - /** - * @test - */ + #[Test] public function isConfirmedReturnsConfirmedState(): void { $this->subject->setConfirmed(true); self::assertTrue($this->subject->isConfirmed()); } - /** - * @test - */ + #[Test] public function getPaidReturnsInitialValueForBoolean(): void { self::assertFalse( @@ -327,44 +268,34 @@ public function getPaidReturnsInitialValueForBoolean(): void ); } - /** - * @test - */ + #[Test] public function setPaidForBooleanSetsPaid(): void { $this->subject->setPaid(true); self::assertTrue($this->subject->getPaid()); } - /** - * @test - */ + #[Test] public function isPaidReturnsPaidState(): void { $this->subject->setPaid(true); self::assertTrue($this->subject->isPaid()); } - /** - * @test - */ + #[Test] public function getNotesReturnsInitialValueForString(): void { self::assertSame('', $this->subject->getNotes()); } - /** - * @test - */ + #[Test] public function setNotesForStringSetsNotes(): void { $this->subject->setNotes('This is a longer text'); self::assertEquals('This is a longer text', $this->subject->getNotes()); } - /** - * @test - */ + #[Test] public function setEventForEventSetsEvent(): void { $event = new Event(); @@ -372,17 +303,13 @@ public function setEventForEventSetsEvent(): void self::assertEquals($event, $this->subject->getEvent()); } - /** - * @test - */ + #[Test] public function getMainRegistrationReturnsInitialValue(): void { self::assertNull($this->subject->getMainRegistration()); } - /** - * @test - */ + #[Test] public function setMainRegistrationForRegistrationSetsRegistration(): void { $registration = new Registration(); @@ -390,17 +317,13 @@ public function setMainRegistrationForRegistrationSetsRegistration(): void self::assertEquals($registration, $this->subject->getMainRegistration()); } - /** - * @test - */ + #[Test] public function getConfirmationUntilReturnsInitialValueForDateTime(): void { self::assertNull($this->subject->getConfirmationUntil()); } - /** - * @test - */ + #[Test] public function setConfirmationUntilForDateTimeSetsConfirmationUntil(): void { $dateTimeFixture = new DateTime(); @@ -408,17 +331,13 @@ public function setConfirmationUntilForDateTimeSetsConfirmationUntil(): void self::assertEquals($dateTimeFixture, $this->subject->getConfirmationUntil()); } - /** - * @test - */ + #[Test] public function getRegistrationDateReturnsInitialValueForDateTime(): void { self::assertNull($this->subject->getRegistrationDate()); } - /** - * @test - */ + #[Test] public function setRegistrationDateForDateTimeSetsRegistrationDate(): void { $dateTimeFixture = new DateTime(); @@ -426,17 +345,13 @@ public function setRegistrationDateForDateTimeSetsRegistrationDate(): void self::assertEquals($dateTimeFixture, $this->subject->getRegistrationDate()); } - /** - * @test - */ + #[Test] public function getDateOfBirthReturnsInitialValueForDateTime(): void { self::assertNull($this->subject->getDateOfBirth()); } - /** - * @test - */ + #[Test] public function setDateOfBirthForDateTimeSetsDateOfBirth(): void { $dateTimeFixture = new DateTime(); @@ -444,9 +359,7 @@ public function setDateOfBirthForDateTimeSetsDateOfBirth(): void self::assertEquals($dateTimeFixture, $this->subject->getDateOfBirth()); } - /** - * @test - */ + #[Test] public function getHiddenReturnsInitialValueForBoolean(): void { self::assertFalse( @@ -454,94 +367,72 @@ public function getHiddenReturnsInitialValueForBoolean(): void ); } - /** - * @test - */ + #[Test] public function setHiddenSetsHiddenFlag(): void { $this->subject->setHidden(true); self::assertTrue($this->subject->getHidden()); } - /** - * @test - */ + #[Test] public function amountOfRegistrationReturnsInitialValue(): void { self::assertEquals(1, $this->subject->getAmountOfRegistrations()); } - /** - * @test - */ + #[Test] public function amountOfRegistrationSetsAmountOfRegistrations(): void { $this->subject->setAmountOfRegistrations(2); self::assertEquals(2, $this->subject->getAmountOfRegistrations()); } - /** - * @test - */ + #[Test] public function ignoreNotificationsReturnsInitialValue(): void { self::assertFalse($this->subject->getIgnoreNotifications()); } - /** - * @test - */ + #[Test] public function ignoreNotificationsCanBeSet(): void { $this->subject->setIgnoreNotifications(true); self::assertTrue($this->subject->getIgnoreNotifications()); } - /** - * @test - */ + #[Test] public function getLanguageReturnsDefaultForString(): void { self::assertEmpty($this->subject->getLanguage()); } - /** - * @test - */ + #[Test] public function setLanguageSetsGivenLanguage(): void { $this->subject->setLanguage('de'); self::assertEquals('de', $this->subject->getLanguage()); } - /** - * @test - */ + #[Test] public function getCaptchaReturnsDefaultForString(): void { self::assertEmpty($this->subject->getCaptcha()); } - /** - * @test - */ + #[Test] public function setCaptchaSetsGivenLanguage(): void { $this->subject->setCaptcha('1234567890'); self::assertEquals('1234567890', $this->subject->getCaptcha()); } - /** - * @test - */ + #[Test] public function getFeUserReturnsInitialValue(): void { self::assertNull($this->subject->getFeUser()); } - /** - * @test - */ + #[Test] public function setFeUserSetsFeUser(): void { $user = new FrontendUser(); @@ -549,43 +440,33 @@ public function setFeUserSetsFeUser(): void self::assertSame($this->subject->getFeUser(), $user); } - /** - * @test - */ + #[Test] public function getPaymentmethodReturnsInitialValue(): void { self::assertEmpty($this->subject->getPaymentmethod()); } - /** - * @test - */ + #[Test] public function setPaymentmethodSetsPaymentmethod(): void { $this->subject->setPaymentmethod('invoice'); self::assertEquals('invoice', $this->subject->getPaymentmethod()); } - /** - * @test - */ + #[Test] public function getPaymentReferenceReturnsInitialValue(): void { self::assertEmpty($this->subject->getPaymentReference()); } - /** - * @test - */ + #[Test] public function setPaymentReferenceSetsPaymentmethod(): void { $this->subject->setPaymentReference('paid-1234567890'); self::assertEquals('paid-1234567890', $this->subject->getPaymentReference()); } - /** - * @test - */ + #[Test] public function getFullnameReturnsExpectedFullname(): void { $this->subject->setFirstname('Torben'); diff --git a/Tests/Unit/Domain/Model/SpeakerTest.php b/Tests/Unit/Domain/Model/SpeakerTest.php index 54f22f7f7..28397fa34 100644 --- a/Tests/Unit/Domain/Model/SpeakerTest.php +++ b/Tests/Unit/Domain/Model/SpeakerTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Domain\Model; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Speaker; use TYPO3\CMS\Extbase\Domain\Model\FileReference; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -29,9 +30,7 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function getNameReturnsInitialValueForString(): void { self::assertSame( @@ -40,18 +39,14 @@ public function getNameReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setNameForStringSetsName(): void { $this->subject->setName('Firstname Lastname'); self::assertSame('Firstname Lastname', $this->subject->getName()); } - /** - * @test - */ + #[Test] public function getJobTitleReturnsInitialValueForString(): void { self::assertSame( @@ -60,18 +55,14 @@ public function getJobTitleReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setJobTitleForStringSetsJobTitle(): void { $this->subject->setJobTitle('Web-Developer'); self::assertSame('Web-Developer', $this->subject->getJobTitle()); } - /** - * @test - */ + #[Test] public function getDescriptionTitleReturnsInitialValueForString(): void { self::assertSame( @@ -80,9 +71,7 @@ public function getDescriptionTitleReturnsInitialValueForString(): void ); } - /** - * @test - */ + #[Test] public function setDescriptionTitleForStringSetsDescription(): void { $this->subject->setDescription('A description'); @@ -91,9 +80,8 @@ public function setDescriptionTitleForStringSetsDescription(): void /** * Test if initial value for image is returned - * - * @test */ + #[Test] public function getImageReturnsInitialValueForImage(): void { self::assertNull($this->subject->getImage()); @@ -101,9 +89,8 @@ public function getImageReturnsInitialValueForImage(): void /** * Test if image can be set - * - * @test */ + #[Test] public function setImageForFileReferenceSetsImage(): void { $image = new FileReference(); diff --git a/Tests/Unit/Evaluation/LatitudeEvaluatorTest.php b/Tests/Unit/Evaluation/LatitudeEvaluatorTest.php index d28264cc2..4ec7c08b4 100644 --- a/Tests/Unit/Evaluation/LatitudeEvaluatorTest.php +++ b/Tests/Unit/Evaluation/LatitudeEvaluatorTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Evaluation; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Evaluation\LatitudeEvaluator; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -65,10 +67,8 @@ public static function latitudeEvaluatorDataProvider(): array ]; } - /** - * @test - * @dataProvider latitudeEvaluatorDataProvider - */ + #[DataProvider('latitudeEvaluatorDataProvider')] + #[Test] public function latitudeEvaluatorTest(string $value, string $expected): void { $set = true; diff --git a/Tests/Unit/Evaluation/LongitudeEvaluatorTest.php b/Tests/Unit/Evaluation/LongitudeEvaluatorTest.php index 97852e795..b784a8996 100644 --- a/Tests/Unit/Evaluation/LongitudeEvaluatorTest.php +++ b/Tests/Unit/Evaluation/LongitudeEvaluatorTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Evaluation; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Evaluation\LongitudeEvaluator; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -65,10 +67,8 @@ public static function longitudeEvaluatorDataProvider(): array ]; } - /** - * @test - * @dataProvider longitudeEvaluatorDataProvider - */ + #[DataProvider('longitudeEvaluatorDataProvider')] + #[Test] public function longitudeEvaluatorTest(string $value, string $expected): void { $set = true; diff --git a/Tests/Unit/Evaluation/TimeRestrictionEvaluatorTest.php b/Tests/Unit/Evaluation/TimeRestrictionEvaluatorTest.php index e658ac6b0..4b280ec62 100644 --- a/Tests/Unit/Evaluation/TimeRestrictionEvaluatorTest.php +++ b/Tests/Unit/Evaluation/TimeRestrictionEvaluatorTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Evaluation; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Evaluation\TimeRestrictionEvaluator; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -57,12 +59,11 @@ public static function timeRestrictionEvaluatorDataProvider(): array } /** - * @test - * @dataProvider timeRestrictionEvaluatorDataProvider - * * @param string $value * @param string $expected */ + #[DataProvider('timeRestrictionEvaluatorDataProvider')] + #[Test] public function timeRestrictionEvaluatorTest($value, $expected) { $set = true; diff --git a/Tests/Unit/Form/FormDataProvider/HideInlineRegistrationsTest.php b/Tests/Unit/Form/FormDataProvider/HideInlineRegistrationsTest.php index 7f56c6b45..e83aea7ad 100644 --- a/Tests/Unit/Form/FormDataProvider/HideInlineRegistrationsTest.php +++ b/Tests/Unit/Form/FormDataProvider/HideInlineRegistrationsTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Form\formDataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Form\FormDataProvider\HideInlineRegistrations; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Localization\LanguageService; @@ -27,9 +28,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @test - */ + #[Test] public function addDataWhenHideInlineRegistrationsIsDisabled(): void { $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['sf_event_mgt'] = [ @@ -54,9 +53,7 @@ public function addDataWhenHideInlineRegistrationsIsDisabled(): void self::assertEquals($expected, (new HideInlineRegistrations())->addData($input)); } - /** - * @test - */ + #[Test] public function addDataWhenHideInlineRegistrationsIsEnabledAndLimitExceeded(): void { $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['sf_event_mgt'] = [ diff --git a/Tests/Unit/Payment/AbstractPaymentTest.php b/Tests/Unit/Payment/AbstractPaymentTest.php index 16dfd47cf..c3661df66 100644 --- a/Tests/Unit/Payment/AbstractPaymentTest.php +++ b/Tests/Unit/Payment/AbstractPaymentTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Payment; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Payment\AbstractPayment; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -28,41 +29,31 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function isEnableRedirectReturnsDefaultValue(): void { self::assertFalse($this->subject->isRedirectEnabled()); } - /** - * @test - */ + #[Test] public function isCancelLinkEnabledReturnsDefaultValue(): void { self::assertFalse($this->subject->isCancelLinkEnabled()); } - /** - * @test - */ + #[Test] public function isNotifyLinkEnabledReturnsDefaultValue(): void { self::assertFalse($this->subject->isNotifyLinkEnabled()); } - /** - * @test - */ + #[Test] public function isSuccessLinkEnabledReturnsDefaultValue(): void { self::assertFalse($this->subject->isSuccessLinkEnabled()); } - /** - * @test - */ + #[Test] public function isFailureLinkEnabledReturnsDefaultValue(): void { self::assertFalse($this->subject->isFailureLinkEnabled()); diff --git a/Tests/Unit/Service/BeUserSessionServiceTest.php b/Tests/Unit/Service/BeUserSessionServiceTest.php index 6b13b29db..aff075523 100644 --- a/Tests/Unit/Service/BeUserSessionServiceTest.php +++ b/Tests/Unit/Service/BeUserSessionServiceTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Service; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; use DERHANSEN\SfEventMgt\Service\BeUserSessionService; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -29,9 +31,7 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function saveSessionDataSavesDataToSession(): void { $data = ['key' => 'value']; @@ -45,9 +45,7 @@ public function saveSessionDataSavesDataToSession(): void $this->subject->saveSessionData($data); } - /** - * @test - */ + #[Test] public function getSessionDataReturnsSessionData(): void { $mockBackendUser = $this->getMockBuilder(BackendUserAuthentication::class) @@ -82,10 +80,8 @@ public static function getSessionDataByKeyDataProvider(): array ]; } - /** - * @test - * @dataProvider getSessionDataByKeyDataProvider - */ + #[DataProvider('getSessionDataByKeyDataProvider')] + #[Test] public function getSessionDataByKeyReturnsExpectedValue(array $sessionData, string $key, ?string $expected): void { $mockBackendUser = $this->getMockBuilder(BackendUserAuthentication::class) diff --git a/Tests/Unit/Service/CalendarServiceTest.php b/Tests/Unit/Service/CalendarServiceTest.php index 8fbb0b016..23d70d8f5 100644 --- a/Tests/Unit/Service/CalendarServiceTest.php +++ b/Tests/Unit/Service/CalendarServiceTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Service; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; use DateTime; use DERHANSEN\SfEventMgt\Domain\Model\Event; use DERHANSEN\SfEventMgt\Service\CalendarService; @@ -33,9 +35,8 @@ protected function tearDown(): void /** * Test if the calendar array returns an expected amount of weeks for a given date - * - * @test */ + #[Test] public function getCalendarArrayReturnsExpectedAmountOfWeeksForGivenDate(): void { $calendarArray = $this->subject->getCalendarArray(1, 2017, mktime(0, 0, 0, 1, 1, 2017), 1); @@ -44,9 +45,8 @@ public function getCalendarArrayReturnsExpectedAmountOfWeeksForGivenDate(): void /** * Test if the calendar array index contains week numbers - * - * @test */ + #[Test] public function getCalendarArrayHasWeekNumbersAsIndex(): void { $calendarArray = $this->subject->getCalendarArray(1, 2017, mktime(0, 0, 0, 1, 1, 2017), 1); @@ -60,9 +60,8 @@ public function getCalendarArrayHasWeekNumbersAsIndex(): void /** * Test, if the first weekday of the calendar is a sunday if the first day of week setting is set to sunday - * - * @test */ + #[Test] public function getCalendarArrayRespectsFirstDayOfWeekParameter(): void { $calendarArray = $this->subject->getCalendarArray(1, 2017, mktime(0, 0, 0, 1, 1, 2017), 0); @@ -71,9 +70,8 @@ public function getCalendarArrayRespectsFirstDayOfWeekParameter(): void /** * Test, if isCurrentDay is set - * - * @test */ + #[Test] public function getCalendarArraySetsIsCurrentDay(): void { $calendarArray = $this->subject->getCalendarArray(1, 2017, mktime(0, 0, 0, 1, 2, 2017), 1); @@ -82,9 +80,8 @@ public function getCalendarArraySetsIsCurrentDay(): void /** * Test, if an event for the 02.01.2017 will be returned in the array - * - * @test */ + #[Test] public function getCalendarArrayReturnsArrayWithEventForOneDay(): void { $mockEvent = $this->getMockBuilder(Event::class)->getMock(); @@ -104,9 +101,8 @@ public function getCalendarArrayReturnsArrayWithEventForOneDay(): void /** * Test, if an event for the 02.01.2017 to 04.01.2017 will be returned in the array - * - * @test */ + #[Test] public function getCalendarArrayReturnsArrayWithEventForMultipleDays(): void { $mockEvent = $this->getMockBuilder(Event::class)->getMock(); @@ -198,10 +194,8 @@ public static function calendarDateRangeDataProvider(): array ]; } - /** - * @test - * @dataProvider calendarDateRangeDataProvider - */ + #[DataProvider('calendarDateRangeDataProvider')] + #[Test] public function getCalendarDateRangeReturnsExpectedValues( int $month, int $year, @@ -248,19 +242,15 @@ public static function dateConfigDataProvider(): array ]; } - /** - * @test - * @dataProvider dateConfigDataProvider - */ + #[DataProvider('dateConfigDataProvider')] + #[Test] public function getDateConfigReturnsExpectedValues(int $month, int $year, string $modifier, array $expected): void { $result = $this->subject->getDateConfig($month, $year, $modifier); self::assertEquals($expected, $result); } - /** - * @test - */ + #[Test] public function getWeekConfigReturnsExpectedValue(): void { $firstDayOfWeek = DateTime::createFromFormat('d.m.Y', '3.1.2022')->setTime(0, 0); diff --git a/Tests/Unit/Service/CaptchaConfigurationServiceTest.php b/Tests/Unit/Service/CaptchaConfigurationServiceTest.php index 9a7bb1122..7e6657058 100644 --- a/Tests/Unit/Service/CaptchaConfigurationServiceTest.php +++ b/Tests/Unit/Service/CaptchaConfigurationServiceTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Service; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; use DERHANSEN\SfEventMgt\Exception\InvalidCaptchaConfigurationException; use DERHANSEN\SfEventMgt\Service\CaptchaConfigurationService; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -38,9 +40,7 @@ class CaptchaConfigurationServiceTest extends UnitTestCase ], ]; - /** - * @test - */ + #[Test] public function captchaConfigurationServiceIsNotEnabledForEmptySettings(): void { $service = new CaptchaConfigurationService(); @@ -157,10 +157,8 @@ public static function captchaConfigurationThrowsExceptionForInvalidSettingsData ]; } - /** - * @test - * @dataProvider captchaConfigurationThrowsExceptionForInvalidSettingsDataProvider - */ + #[DataProvider('captchaConfigurationThrowsExceptionForInvalidSettingsDataProvider')] + #[Test] public function captchaConfigurationThrowsExceptionForInvalidSettings(array $settings, int $code): void { $this->expectException(InvalidCaptchaConfigurationException::class); @@ -241,10 +239,8 @@ public static function gettersReturnExpectedResultDataProvider(): array ]; } - /** - * @test - * @dataProvider gettersReturnExpectedResultDataProvider - */ + #[DataProvider('gettersReturnExpectedResultDataProvider')] + #[Test] public function gettersReturnExpectedResult(array $settings, string $method, $expected): void { $service = new CaptchaConfigurationService($settings); diff --git a/Tests/Unit/Service/EmailServiceTest.php b/Tests/Unit/Service/EmailServiceTest.php index 2efb7b8ed..66bfb0b48 100644 --- a/Tests/Unit/Service/EmailServiceTest.php +++ b/Tests/Unit/Service/EmailServiceTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Service; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Service\EmailService; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -44,10 +46,9 @@ public static function invalidEmailsDataProvider(): array /** * Test if email-service returns false, if emails are invalid - * - * @dataProvider invalidEmailsDataProvider - * @test */ + #[DataProvider('invalidEmailsDataProvider')] + #[Test] public function sendEmailMessageWithInvalidEmailTest(string $sender, string $recipient) { $subject = 'A subject'; diff --git a/Tests/Unit/Service/EventPlausabilityServiceTest.php b/Tests/Unit/Service/EventPlausabilityServiceTest.php index 60fb3de77..b33f82bee 100644 --- a/Tests/Unit/Service/EventPlausabilityServiceTest.php +++ b/Tests/Unit/Service/EventPlausabilityServiceTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Service; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Service\EventPlausabilityService; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -45,19 +47,15 @@ public static function isStartDateBeforeEndDateDataProvider(): array ]; } - /** - * @test - * @dataProvider isStartDateBeforeEndDateDataProvider - */ + #[DataProvider('isStartDateBeforeEndDateDataProvider')] + #[Test] public function isStartDateBeforeEndDateReturnsExpectedResults(int $startdate, int $enddate, bool $expected): void { $service = $this->getAccessibleMock(EventPlausabilityService::class, null, [], '', false); self::assertEquals($expected, $service->_call('isStartDateBeforeEndDate', $startdate, $enddate)); } - /** - * @test - */ + #[Test] public function verifyOrganisatorConfigurationWithNoOrganisatorAndDisabledRegistrationAddsNoFlashMessage(): void { $languageService = $this->createMock(LanguageService::class); @@ -73,9 +71,7 @@ public function verifyOrganisatorConfigurationWithNoOrganisatorAndDisabledRegist $service->verifyOrganisatorConfiguration($databaseRow); } - /** - * @test - */ + #[Test] public function verifyOrganisatorConfigurationWithNoOrganisatorAddsFlashMessage(): void { $languageService = $this->createMock(LanguageService::class); @@ -91,9 +87,7 @@ public function verifyOrganisatorConfigurationWithNoOrganisatorAddsFlashMessage( $service->verifyOrganisatorConfiguration($databaseRow); } - /** - * @test - */ + #[Test] public function verifyOrganisatorConfigurationWithOrganisatorAndNoEmailAddsFlashMessage(): void { $languageService = $this->createMock(LanguageService::class); @@ -116,9 +110,7 @@ public function verifyOrganisatorConfigurationWithOrganisatorAndNoEmailAddsFlash $service->verifyOrganisatorConfiguration($databaseRow); } - /** - * @test - */ + #[Test] public function verifyOrganisatorConfigurationWithOrganisatorAndValidEmailAddsNoFlashMessage(): void { $languageService = $this->createMock(LanguageService::class); diff --git a/Tests/Unit/Service/ExportServiceTest.php b/Tests/Unit/Service/ExportServiceTest.php index a69027f43..cb624bee1 100644 --- a/Tests/Unit/Service/ExportServiceTest.php +++ b/Tests/Unit/Service/ExportServiceTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Service; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Event; use DERHANSEN\SfEventMgt\Domain\Model\Registration; use DERHANSEN\SfEventMgt\Domain\Repository\EventRepository; @@ -98,10 +100,8 @@ public static function fieldValuesInTypoScriptDataProvider(): array ]; } - /** - * @test - * @dataProvider fieldValuesInTypoScriptDataProvider - */ + #[DataProvider('fieldValuesInTypoScriptDataProvider')] + #[Test] public function exportServiceWorksWithDifferentFormattedTypoScriptValues( int $uid, array $fields, diff --git a/Tests/Unit/Service/FluidStandaloneServiceTest.php b/Tests/Unit/Service/FluidStandaloneServiceTest.php index 2a19f4c3c..a61f683c5 100644 --- a/Tests/Unit/Service/FluidStandaloneServiceTest.php +++ b/Tests/Unit/Service/FluidStandaloneServiceTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Service; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; use DERHANSEN\SfEventMgt\Service\FluidStandaloneService; use TYPO3\CMS\Core\Http\ServerRequest; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -34,9 +36,7 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function getTemplateFoldersReturnsDefaultPathForNoConfiguration(): void { $configurationManager = $this->getMockBuilder(ConfigurationManager::class) @@ -51,9 +51,7 @@ public function getTemplateFoldersReturnsDefaultPathForNoConfiguration(): void self::assertEquals($expected, $this->subject->getTemplateFolders()); } - /** - * @test - */ + #[Test] public function renderTemplateReturnsExpectedResult(): void { $serverRequest = new ServerRequest(); @@ -145,10 +143,8 @@ public static function templateFoldersDataProvider(): array ]; } - /** - * @test - * @dataProvider templateFoldersDataProvider - */ + #[DataProvider('templateFoldersDataProvider')] + #[Test] public function getTemplateFoldersReturnsExpectedResult(array $settings, array $expected): void { $configurationManager = $this->getMockBuilder(ConfigurationManager::class) diff --git a/Tests/Unit/Service/ICalendarServiceTest.php b/Tests/Unit/Service/ICalendarServiceTest.php index 25c630e93..5ad6c9e74 100644 --- a/Tests/Unit/Service/ICalendarServiceTest.php +++ b/Tests/Unit/Service/ICalendarServiceTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Service; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Event; use DERHANSEN\SfEventMgt\Service\FluidStandaloneService; use DERHANSEN\SfEventMgt\Service\ICalendarService; @@ -30,9 +31,7 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function getiCalendarContentAssignsVariablesToView(): void { $_SERVER['HTTP_HOST'] = 'myhostname.tld'; diff --git a/Tests/Unit/Service/Notification/AttachmentServiceTest.php b/Tests/Unit/Service/Notification/AttachmentServiceTest.php index a8538e7cb..ca2565ae6 100644 --- a/Tests/Unit/Service/Notification/AttachmentServiceTest.php +++ b/Tests/Unit/Service/Notification/AttachmentServiceTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Service\Notification; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Event; use DERHANSEN\SfEventMgt\Domain\Model\Registration; use DERHANSEN\SfEventMgt\Service\ICalendarService; @@ -106,13 +108,13 @@ public static function typoScriptConfigTestDataProvider(): array * Tests if TypoScript settings are respected for the configured MessageTypes * and expected fromFiles result are returned * - * @test - * @dataProvider typoScriptConfigTestDataProvider * @param mixed $messageType * @param mixed $messageRecipient * @param mixed $settingsPath * @param mixed $expected */ + #[DataProvider('typoScriptConfigTestDataProvider')] + #[Test] public function getAttachmentsRespectsTypoScriptSettingsForGivenMessageType( $messageType, $messageRecipient, @@ -142,8 +144,8 @@ public function getAttachmentsRespectsTypoScriptSettingsForGivenMessageType( /** * Tests if fromEventProperty returns expected attachments for objectStorage property - * @test */ + #[Test] public function getAttachmentsReturnsAttachmentsFromEventPropertyWithObjectStorage() { $registration = new Registration(); @@ -199,8 +201,8 @@ public function getAttachmentsReturnsAttachmentsFromEventPropertyWithObjectStora /** * Tests if fromRegistrationProperty returns expected attachments for FileReference property - * @test */ + #[Test] public function getAttachmentsReturnsAttachmentsFromEventPropertyWithFileReference() { $event = new Event(); @@ -246,9 +248,7 @@ public function getAttachmentsReturnsAttachmentsFromEventPropertyWithFileReferen self::assertEquals($expected, $attachments); } - /** - * @test - */ + #[Test] public function getICalAttachmentReturnsAFilenameIfICalFileEnabled() { $event = new Event(); diff --git a/Tests/Unit/Service/NotificationServiceTest.php b/Tests/Unit/Service/NotificationServiceTest.php index 6d194563a..d7e9e4cca 100644 --- a/Tests/Unit/Service/NotificationServiceTest.php +++ b/Tests/Unit/Service/NotificationServiceTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Service; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Dto\CustomNotification; use DERHANSEN\SfEventMgt\Domain\Model\Event; use DERHANSEN\SfEventMgt\Domain\Model\Organisator; @@ -64,10 +66,8 @@ public static function messageTypeDataProvider(): array ]; } - /** - * @test - * @dataProvider messageTypeDataProvider - */ + #[DataProvider('messageTypeDataProvider')] + #[Test] public function sendUserMessageReturnsFalseIfIgnoreNotificationsSet(int $messageType): void { $event = new Event(); @@ -81,10 +81,8 @@ public function sendUserMessageReturnsFalseIfIgnoreNotificationsSet(int $message self::assertFalse($result); } - /** - * @test - * @dataProvider messageTypeDataProvider - */ + #[DataProvider('messageTypeDataProvider')] + #[Test] public function sendUserMessageReturnsFalseIfSendFailed(int $messageType): void { $event = new Event(); @@ -121,10 +119,8 @@ public function sendUserMessageReturnsFalseIfSendFailed(int $messageType): void self::assertFalse($result); } - /** - * @test - * @dataProvider messageTypeDataProvider - */ + #[DataProvider('messageTypeDataProvider')] + #[Test] public function sendUserMessageReturnsTrueIfSendSuccessful(int $messageType): void { $event = new Event(); @@ -162,10 +158,8 @@ public function sendUserMessageReturnsTrueIfSendSuccessful(int $messageType): vo self::assertTrue($result); } - /** - * @test - * @dataProvider messageTypeDataProvider - */ + #[DataProvider('messageTypeDataProvider')] + #[Test] public function sendAdminNewRegistrationMessageReturnsFalseIfSendFailed(int $messageType): void { $event = new Event(); @@ -208,10 +202,8 @@ public function sendAdminNewRegistrationMessageReturnsFalseIfSendFailed(int $mes self::assertFalse($result); } - /** - * @test - * @dataProvider messageTypeDataProvider - */ + #[DataProvider('messageTypeDataProvider')] + #[Test] public function sendAdminNewRegistrationMessageReturnsTrueIfSendSuccessful(int $messageType): void { $event = new Event(); @@ -254,10 +246,8 @@ public function sendAdminNewRegistrationMessageReturnsTrueIfSendSuccessful(int $ self::assertTrue($result); } - /** - * @test - * @dataProvider messageTypeDataProvider - */ + #[DataProvider('messageTypeDataProvider')] + #[Test] public function sendAdminMessageDoesNotSendEmailIfNotifyAdminAndNotifyOrganiserIsFalse(int $messageType): void { $event = new Event(); @@ -280,10 +270,8 @@ public function sendAdminMessageDoesNotSendEmailIfNotifyAdminAndNotifyOrganiserI self::assertFalse($result); } - /** - * @test - * @dataProvider messageTypeDataProvider - */ + #[DataProvider('messageTypeDataProvider')] + #[Test] public function sendAdminMessageSendsEmailToOrganisatorIfConfigured(int $messageType): void { $organisator = new Organisator(); @@ -330,9 +318,7 @@ public function sendAdminMessageSendsEmailToOrganisatorIfConfigured(int $message self::assertTrue($result); } - /** - * @test - */ + #[Test] public function sendAdminMessageUsesRegistrationDataAsSenderIfConfigured(): void { $organisator = new Organisator(); @@ -382,10 +368,9 @@ public function sendAdminMessageUsesRegistrationDataAsSenderIfConfigured(): void /** * Test if the adminEmail settings get exploded and only 2 emails get sent - * - * @test - * @dataProvider messageTypeDataProvider */ + #[DataProvider('messageTypeDataProvider')] + #[Test] public function sendMultipleAdminNewRegistrationMessageReturnsTrueIfSendSuccessful(int $messageType): void { $event = new Event(); @@ -428,9 +413,7 @@ public function sendMultipleAdminNewRegistrationMessageReturnsTrueIfSendSuccessf self::assertTrue($result); } - /** - * @test - */ + #[Test] public function sendUserMessageReturnsFalseIfNoCustomMessageGiven(): void { $event = new Event(); @@ -452,9 +435,8 @@ public function sendUserMessageReturnsFalseIfNoCustomMessageGiven(): void /** * Test that only confirmed registrations get notified. Also test, if the ignoreNotifications * flag is evaluated - * - * @test */ + #[Test] public function sendCustomNotificationReturnsExpectedAmountOfNotificationsSent(): void { $event = new Event(); @@ -488,9 +470,7 @@ public function sendCustomNotificationReturnsExpectedAmountOfNotificationsSent() self::assertEquals(2, $result); } - /** - * @test - */ + #[Test] public function createCustomNotificationLogentryCreatesLog(): void { $mockLogRepo = $this->getMockBuilder(CustomNotificationLogRepository::class) @@ -508,9 +488,7 @@ public function createCustomNotificationLogentryCreatesLog(): void $this->subject->createCustomNotificationLogentry($event, 'A description', 1, new CustomNotification()); } - /** - * @test - */ + #[Test] public function userNotificationNotSentIfNotificationsDisabled(): void { $event = $this->getMockBuilder(Event::class)->getMock(); @@ -529,9 +507,7 @@ public function userNotificationNotSentIfNotificationsDisabled(): void self::assertFalse($result); } - /** - * @test - */ + #[Test] public function adminNotificationNotSentIfNotificationsDisabled(): void { $event = $this->getMockBuilder(Event::class)->getMock(); diff --git a/Tests/Unit/Service/PaymentServiceTest.php b/Tests/Unit/Service/PaymentServiceTest.php index d71248257..f10f04148 100644 --- a/Tests/Unit/Service/PaymentServiceTest.php +++ b/Tests/Unit/Service/PaymentServiceTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Service; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Payment\Invoice; use DERHANSEN\SfEventMgt\Payment\Transfer; use DERHANSEN\SfEventMgt\Service\PaymentService; @@ -59,10 +61,8 @@ public static function getPaymentMethodsDataProvider(): array ]; } - /** - * @test - * @dataProvider getPaymentMethodsDataProvider - */ + #[DataProvider('getPaymentMethodsDataProvider')] + #[Test] public function getPaymentMethodsReturnsDefaultPaymentMethods(array $extConf, array $expected): void { $this->subject = $this->getAccessibleMock(PaymentService::class, ['translate'], [], '', false); @@ -70,18 +70,14 @@ public function getPaymentMethodsReturnsDefaultPaymentMethods(array $extConf, ar self::assertEquals($expected, $this->subject->getPaymentMethods()); } - /** - * @test - */ + #[Test] public function getPaymentInstanceReturnsInvoicePaymentInsance(): void { $this->subject = new PaymentService(); self::assertInstanceOf(Invoice::class, $this->subject->getPaymentInstance('invoice')); } - /** - * @test - */ + #[Test] public function getPaymentInstanceReturnsTransferPaymentInsance(): void { $this->subject = new PaymentService(); @@ -114,10 +110,8 @@ public static function paymentActionEnabledForDefaultPaymentMethodDataProvider() ]; } - /** - * @test - * @dataProvider paymentActionEnabledForDefaultPaymentMethodDataProvider - */ + #[DataProvider('paymentActionEnabledForDefaultPaymentMethodDataProvider')] + #[Test] public function paymentActionEnabledForDefaultPaymentMethodReturnsExpectedResult(string $action, bool $expected): void { $this->subject = $this->getAccessibleMock(PaymentService::class, ['getPaymentInstance'], [], '', false); @@ -152,10 +146,8 @@ public static function paymentActionEnabledForCustomPaymentMethodDataProvider(): ]; } - /** - * @test - * @dataProvider paymentActionEnabledForCustomPaymentMethodDataProvider - */ + #[DataProvider('paymentActionEnabledForCustomPaymentMethodDataProvider')] + #[Test] public function paymentActionEnabledForCustomPaymentMethodReturnsExpectedResult(string $action, bool $expected): void { $mockPaymentInstance = $this->getAccessibleMock( diff --git a/Tests/Unit/Service/RegistrationServiceTest.php b/Tests/Unit/Service/RegistrationServiceTest.php index 1af4693ba..818163ee6 100644 --- a/Tests/Unit/Service/RegistrationServiceTest.php +++ b/Tests/Unit/Service/RegistrationServiceTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Service; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; use DateInterval; use DateTime; use DERHANSEN\SfEventMgt\Domain\Model\Event; @@ -48,9 +50,7 @@ protected function tearDown(): void unset($this->subject); } - /** - * @test - */ + #[Test] public function createDependingRegistrationsCreatesAmountOfExpectedRegistrations(): void { GeneralUtility::setSingletonInstance(ReflectionService::class, new ReflectionService(new NullFrontend('extbase'), 'ClassSchemata')); @@ -69,9 +69,7 @@ public function createDependingRegistrationsCreatesAmountOfExpectedRegistrations $this->subject->createDependingRegistrations($registration); } - /** - * @test - */ + #[Test] public function confirmDependingRegistrationsConfirmsDependingRegistrations(): void { $mockRegistration = $this->getMockBuilder(Registration::class)->disableOriginalConstructor()->getMock(); @@ -93,9 +91,7 @@ public function confirmDependingRegistrationsConfirmsDependingRegistrations(): v $this->subject->confirmDependingRegistrations($mockRegistration); } - /** - * @test - */ + #[Test] public function cancelDependingRegistrationsRemovesDependingRegistrations(): void { $mockRegistration = $this->getMockBuilder(Registration::class)->disableOriginalConstructor()->getMock(); @@ -116,9 +112,8 @@ public function cancelDependingRegistrationsRemovesDependingRegistrations(): voi /** * Test if expected array is returned if HMAC validations fails - * - * @test */ + #[Test] public function checkConfirmRegistrationIfHmacValidationFailsTest(): void { $reguid = 1; @@ -143,9 +138,8 @@ public function checkConfirmRegistrationIfHmacValidationFailsTest(): void /** * Test if expected array is returned if no Registration found - * - * @test */ + #[Test] public function checkConfirmRegistrationIfNoRegistrationTest(): void { $reguid = 1; @@ -177,9 +171,8 @@ public function checkConfirmRegistrationIfNoRegistrationTest(): void /** * Test if expected array is returned registration has no event - * - * @test */ + #[Test] public function checkConfirmRegistrationIfNoRegistrationEventTest(): void { $reguid = 1; @@ -213,9 +206,8 @@ public function checkConfirmRegistrationIfNoRegistrationEventTest(): void /** * Test if expected array is returned if confirmation date expired - * - * @test */ + #[Test] public function checkConfirmRegistrationIfConfirmationDateExpiredTest(): void { $reguid = 1; @@ -251,9 +243,8 @@ public function checkConfirmRegistrationIfConfirmationDateExpiredTest(): void /** * Test if expected array is returned if registration already confirmed - * - * @test */ + #[Test] public function checkConfirmRegistrationIfRegistrationConfirmedTest(): void { $reguid = 1; @@ -290,9 +281,8 @@ public function checkConfirmRegistrationIfRegistrationConfirmedTest(): void /** * Test if expected array is returned if HMAC validations fails - * - * @test */ + #[Test] public function checkCancelRegistrationIfHmacValidationFailsTest(): void { $reguid = 1; @@ -317,9 +307,8 @@ public function checkCancelRegistrationIfHmacValidationFailsTest(): void /** * Test if expected array is returned if no Registration found - * - * @test */ + #[Test] public function checkCancelRegistrationIfNoRegistrationTest(): void { $reguid = 1; @@ -351,9 +340,8 @@ public function checkCancelRegistrationIfNoRegistrationTest(): void /** * Test if expected array is returned if cancellation is not enabled - * - * @test */ + #[Test] public function checkCancelRegistrationIfCancellationIsNotEnabledTest(): void { $reguid = 1; @@ -391,9 +379,8 @@ public function checkCancelRegistrationIfCancellationIsNotEnabledTest(): void /** * Test if expected array is returned if cancellation deadline expired - * - * @test */ + #[Test] public function checkCancelRegistrationIfCancellationDeadlineExpiredTest(): void { $reguid = 1; @@ -432,9 +419,8 @@ public function checkCancelRegistrationIfCancellationDeadlineExpiredTest(): void /** * Test if expected array is returned if event startdate passed - * - * @test */ + #[Test] public function checkCancelRegistrationIfEventStartdatePassedTest(): void { $reguid = 1; @@ -474,9 +460,8 @@ public function checkCancelRegistrationIfEventStartdatePassedTest(): void /** * Test if expected value is returned if no frontend user logged in - * - * @test */ + #[Test] public function getCurrentFeUserObjectReturnsNullIfNoFeUser(): void { $GLOBALS['TSFE'] = new stdClass(); @@ -487,9 +472,8 @@ public function getCurrentFeUserObjectReturnsNullIfNoFeUser(): void /** * Test if expected value is returned if a frontend user logged in - * - * @test */ + #[Test] public function getCurrentFeUserObjectReturnsFeUser(): void { $GLOBALS['TSFE'] = new stdClass(); @@ -509,9 +493,7 @@ public function getCurrentFeUserObjectReturnsFeUser(): void self::assertEquals($this->subject->getCurrentFeUserObject(), $feUser); } - /** - * @test - */ + #[Test] public function checkRegistrationSuccessFailsIfRegistrationNotEnabled(): void { $registration = $this->getMockBuilder(Registration::class)->getMock(); @@ -525,9 +507,7 @@ public function checkRegistrationSuccessFailsIfRegistrationNotEnabled(): void self::assertEquals($result, RegistrationResult::REGISTRATION_NOT_ENABLED); } - /** - * @test - */ + #[Test] public function checkRegistrationSuccessFailsIfRegistrationDeadlineExpired(): void { $registration = $this->getMockBuilder(Registration::class)->getMock(); @@ -544,9 +524,7 @@ public function checkRegistrationSuccessFailsIfRegistrationDeadlineExpired(): vo self::assertEquals($result, RegistrationResult::REGISTRATION_FAILED_DEADLINE_EXPIRED); } - /** - * @test - */ + #[Test] public function checkRegistrationSuccessFailsIfEventHasStarted(): void { $registration = $this->getMockBuilder(Registration::class)->getMock(); @@ -563,9 +541,7 @@ public function checkRegistrationSuccessFailsIfEventHasStarted(): void self::assertEquals($result, RegistrationResult::REGISTRATION_FAILED_EVENT_EXPIRED); } - /** - * @test - */ + #[Test] public function checkRegistrationSuccessFailsIfEventHasEndedAndRegistrationUntilEnddateIsAllowed(): void { $registration = $this->getMockBuilder(Registration::class)->getMock(); @@ -585,9 +561,7 @@ public function checkRegistrationSuccessFailsIfEventHasEndedAndRegistrationUntil self::assertEquals($result, RegistrationResult::REGISTRATION_FAILED_EVENT_ENDED); } - /** - * @test - */ + #[Test] public function checkRegistrationSuccessFailsIfMaxParticipantsReached(): void { $registration = $this->getMockBuilder(Registration::class)->getMock(); @@ -612,9 +586,7 @@ public function checkRegistrationSuccessFailsIfMaxParticipantsReached(): void self::assertEquals($result, RegistrationResult::REGISTRATION_FAILED_MAX_PARTICIPANTS); } - /** - * @test - */ + #[Test] public function checkRegistrationSuccessFailsIfAmountOfRegistrationsGreaterThanRemainingPlaces(): void { $registration = $this->getMockBuilder(Registration::class) @@ -643,9 +615,7 @@ public function checkRegistrationSuccessFailsIfAmountOfRegistrationsGreaterThanR self::assertEquals($result, RegistrationResult::REGISTRATION_FAILED_NOT_ENOUGH_FREE_PLACES); } - /** - * @test - */ + #[Test] public function checkRegistrationSuccessFailsIfUniqueEmailCheckEnabledAndEmailRegisteredToEvent(): void { $registration = $this->getMockBuilder(Registration::class)->getMock(); @@ -677,9 +647,7 @@ public function checkRegistrationSuccessFailsIfUniqueEmailCheckEnabledAndEmailRe self::assertEquals($result, RegistrationResult::REGISTRATION_FAILED_EMAIL_NOT_UNIQUE); } - /** - * @test - */ + #[Test] public function checkRegistrationSuccessFailsIfAmountOfRegistrationsExceedsMaxAmountOfRegistrations(): void { $registration = $this->getMockBuilder(Registration::class)->getMock(); @@ -707,9 +675,7 @@ public function checkRegistrationSuccessFailsIfAmountOfRegistrationsExceedsMaxAm self::assertEquals($result, RegistrationResult::REGISTRATION_FAILED_MAX_AMOUNT_REGISTRATIONS_EXCEEDED); } - /** - * @test - */ + #[Test] public function checkRegistrationSuccessSucceedsWhenAllConditionsMet(): void { $registration = $this->getMockBuilder(Registration::class)->getMock(); @@ -734,9 +700,7 @@ public function checkRegistrationSuccessSucceedsWhenAllConditionsMet(): void self::assertEquals($result, RegistrationResult::REGISTRATION_SUCCESSFUL); } - /** - * @test - */ + #[Test] public function checkRegistrationSuccessSucceedsIfEventHasStartedAndRegistrationUntilEnddateIsAllowed(): void { $registration = $this->getMockBuilder(Registration::class)->getMock(); @@ -764,9 +728,7 @@ public function checkRegistrationSuccessSucceedsIfEventHasStartedAndRegistration self::assertEquals($result, RegistrationResult::REGISTRATION_SUCCESSFUL); } - /** - * @test - */ + #[Test] public function redirectPaymentEnabledReturnsFalseIfPaymentNotEnabled(): void { $event = new Event(); @@ -778,9 +740,7 @@ public function redirectPaymentEnabledReturnsFalseIfPaymentNotEnabled(): void self::assertFalse($this->subject->redirectPaymentEnabled($mockRegistration)); } - /** - * @test - */ + #[Test] public function redirectPaymentEnabledReturnsTrueIfPaymentRedirectEnabled() { $event = new Event(); @@ -808,9 +768,7 @@ public function redirectPaymentEnabledReturnsTrueIfPaymentRedirectEnabled() self::assertTrue($this->subject->redirectPaymentEnabled($mockRegistration)); } - /** - * @test - */ + #[Test] public function isWaitlistRegistrationReturnsFalseIfEventNotFullyBookedAndEnoughFreePlaces(): void { $registrations = $this->getMockBuilder(ObjectStorage::class) @@ -827,9 +785,7 @@ public function isWaitlistRegistrationReturnsFalseIfEventNotFullyBookedAndEnough self::assertFalse($this->subject->isWaitlistRegistration($event, 3)); } - /** - * @test - */ + #[Test] public function isWaitlistRegistrationReturnsTrueIfEventNotFullyBookedAndNotEnoughFreePlaces(): void { $registrations = $this->getMockBuilder(ObjectStorage::class) @@ -846,9 +802,7 @@ public function isWaitlistRegistrationReturnsTrueIfEventNotFullyBookedAndNotEnou self::assertTrue($this->subject->isWaitlistRegistration($event, 2)); } - /** - * @test - */ + #[Test] public function isWaitlistRegistrationReturnsTrueIfEventFullyBookedAndNotEnoughFreePlaces(): void { $registrations = $this->getMockBuilder(ObjectStorage::class) @@ -886,10 +840,8 @@ public static function moveUpWaitlistRegistrationsDataProvider(): array ]; } - /** - * @test - * @dataProvider moveUpWaitlistRegistrationsDataProvider - */ + #[DataProvider('moveUpWaitlistRegistrationsDataProvider')] + #[Test] public function moveUpWaitlistRegistrationDoesNotProceedIfCriteriaNotMatch( bool $enableWaitlistMoveup, int $amountWaitlistRegistrations, diff --git a/Tests/Unit/Service/SettingsServiceTest.php b/Tests/Unit/Service/SettingsServiceTest.php index 3a688fb8e..2bf50979b 100644 --- a/Tests/Unit/Service/SettingsServiceTest.php +++ b/Tests/Unit/Service/SettingsServiceTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Service; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Service\SettingsService; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -71,10 +73,8 @@ public static function customNotificationsSettingsDataProvider(): array ]; } - /** - * @test - * @dataProvider customNotificationsSettingsDataProvider - */ + #[DataProvider('customNotificationsSettingsDataProvider')] + #[Test] public function getCustomNotificationsTest(array $settings, array $expected): void { $result = $this->subject->getCustomNotifications($settings); diff --git a/Tests/Unit/Service/SpamCheckServiceTest.php b/Tests/Unit/Service/SpamCheckServiceTest.php index 7776b7921..bf0805d08 100644 --- a/Tests/Unit/Service/SpamCheckServiceTest.php +++ b/Tests/Unit/Service/SpamCheckServiceTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Service; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; use DERHANSEN\SfEventMgt\Domain\Model\Registration; use DERHANSEN\SfEventMgt\Service\SpamCheckService; use DERHANSEN\SfEventMgt\SpamChecks\Exceptions\SpamCheckNotFoundException; @@ -20,9 +22,7 @@ class SpamCheckServiceTest extends UnitTestCase { protected bool $resetSingletonInstances = true; - /** - * @test - */ + #[Test] public function spamCheckServiceWorksForEmptySettingsAndArguments(): void { $registration = new Registration(); @@ -52,10 +52,8 @@ public static function isSpamCheckFailedReturnsFalseForExpectedConditionsDataPro ]; } - /** - * @test - * @dataProvider isSpamCheckFailedReturnsFalseForExpectedConditionsDataProvider - */ + #[DataProvider('isSpamCheckFailedReturnsFalseForExpectedConditionsDataProvider')] + #[Test] public function isSpamCheckFailedReturnsFalseForExpectedConditions(array $settings): void { $registration = new Registration(); @@ -64,9 +62,7 @@ public function isSpamCheckFailedReturnsFalseForExpectedConditions(array $settin self::assertFalse($service->isSpamCheckFailed()); } - /** - * @test - */ + #[Test] public function spamCheckServiceThrowsExceptionWhenTestNotFound(): void { $this->expectException(SpamCheckNotFoundException::class); @@ -84,9 +80,7 @@ public function spamCheckServiceThrowsExceptionWhenTestNotFound(): void $service->isSpamCheckFailed(); } - /** - * @test - */ + #[Test] public function maxSpamScoreIsSetInConstructor(): void { $registration = new Registration(); @@ -100,9 +94,7 @@ public function maxSpamScoreIsSetInConstructor(): void self::assertEquals(20, $service->_get('maxSpamScore')); } - /** - * @test - */ + #[Test] public function emptyCheckArrayIsInitializedInConstructor(): void { $registration = new Registration(); @@ -115,9 +107,7 @@ public function emptyCheckArrayIsInitializedInConstructor(): void self::assertEquals([], $service->_get('settings')['checks']); } - /** - * @test - */ + #[Test] public function configuredSpamCheckIsProcessed(): void { $registration = new Registration(); diff --git a/Tests/Unit/SpamChecks/ChallengeResponseSpamCheckTest.php b/Tests/Unit/SpamChecks/ChallengeResponseSpamCheckTest.php index fffc3b9ae..2847b5366 100644 --- a/Tests/Unit/SpamChecks/ChallengeResponseSpamCheckTest.php +++ b/Tests/Unit/SpamChecks/ChallengeResponseSpamCheckTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\SpamChecks; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Registration; use DERHANSEN\SfEventMgt\SpamChecks\ChallengeResponseSpamCheck; use DERHANSEN\SfEventMgt\Utility\MiscUtility; @@ -24,9 +25,7 @@ public function setUp(): void $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = 'foo'; } - /** - * @test - */ + #[Test] public function checkIsFailedWhenArgumentNotSet(): void { $registration = new Registration(); @@ -38,9 +37,7 @@ public function checkIsFailedWhenArgumentNotSet(): void self::assertTrue($check->isFailed()); } - /** - * @test - */ + #[Test] public function checkIsFailedWhenChallengeResponseDoesNotMatch(): void { $registration = new Registration(); @@ -60,9 +57,7 @@ public function checkIsFailedWhenChallengeResponseDoesNotMatch(): void self::assertTrue($check->isFailed()); } - /** - * @test - */ + #[Test] public function checkIsSuccessfulWhenChallengeResponseIsValid(): void { $registration = new Registration(); diff --git a/Tests/Unit/SpamChecks/HoneypotSpamCheckTest.php b/Tests/Unit/SpamChecks/HoneypotSpamCheckTest.php index 95e2f0296..a91b3ca17 100644 --- a/Tests/Unit/SpamChecks/HoneypotSpamCheckTest.php +++ b/Tests/Unit/SpamChecks/HoneypotSpamCheckTest.php @@ -11,15 +11,14 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\SpamChecks; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Registration; use DERHANSEN\SfEventMgt\SpamChecks\HoneypotSpamCheck; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; class HoneypotSpamCheckTest extends UnitTestCase { - /** - * @test - */ + #[Test] public function checkIsFailedWhenHoneypotFieldNotSubmitted(): void { /** @var Registration $mockRegistration */ @@ -35,9 +34,7 @@ public function checkIsFailedWhenHoneypotFieldNotSubmitted(): void self::assertTrue($check->isFailed()); } - /** - * @test - */ + #[Test] public function checkIsFailedWhenHoneypotFieldFilled(): void { /** @var Registration $mockRegistration */ @@ -55,9 +52,7 @@ public function checkIsFailedWhenHoneypotFieldFilled(): void self::assertTrue($check->isFailed()); } - /** - * @test - */ + #[Test] public function checkIsNotFailedWhenHoneypotFieldEmpty(): void { /** @var Registration $mockRegistration */ diff --git a/Tests/Unit/SpamChecks/LinksSpamCheckTest.php b/Tests/Unit/SpamChecks/LinksSpamCheckTest.php index 5d855ff18..75c5e1d1e 100644 --- a/Tests/Unit/SpamChecks/LinksSpamCheckTest.php +++ b/Tests/Unit/SpamChecks/LinksSpamCheckTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\SpamChecks; +use PHPUnit\Framework\Attributes\Test; +use DERHANSEN\SfEventMgt\Domain\Model\Registration\FieldValue; use DERHANSEN\SfEventMgt\Domain\Model\Registration; use DERHANSEN\SfEventMgt\SpamChecks\LinkSpamCheck; use TYPO3\CMS\Extbase\Persistence\ObjectStorage; @@ -18,9 +20,7 @@ class LinksSpamCheckTest extends UnitTestCase { - /** - * @test - */ + #[Test] public function fallbackToDefaultMaxAmountOfLinksIfConfigurationEmpty(): void { $registration = new Registration(); @@ -35,9 +35,7 @@ public function fallbackToDefaultMaxAmountOfLinksIfConfigurationEmpty(): void self::assertTrue($check->isFailed()); } - /** - * @test - */ + #[Test] public function checkIsFailedWhenConfiguredAmountOfLinksIsExceeded(): void { $registration = new Registration(); @@ -54,12 +52,10 @@ public function checkIsFailedWhenConfiguredAmountOfLinksIsExceeded(): void self::assertTrue($check->isFailed()); } - /** - * @test - */ + #[Test] public function checkIsFailedWhenConfiguredAmountOfLinksIsExceededInRegistrationField(): void { - $registrationFieldValue = new Registration\FieldValue(); + $registrationFieldValue = new FieldValue(); $registrationFieldValue->setValue('https://www.derhansen.com'); $objectStorage = new ObjectStorage(); $objectStorage->attach($registrationFieldValue); @@ -76,9 +72,7 @@ public function checkIsFailedWhenConfiguredAmountOfLinksIsExceededInRegistration self::assertTrue($check->isFailed()); } - /** - * @test - */ + #[Test] public function checkIsNotFailedWhenConfiguredAmountOfLinksIsNotExceeded(): void { $registration = new Registration(); diff --git a/Tests/Unit/Utility/ArrayUtilityTest.php b/Tests/Unit/Utility/ArrayUtilityTest.php index 9ab023391..d18acfea8 100644 --- a/Tests/Unit/Utility/ArrayUtilityTest.php +++ b/Tests/Unit/Utility/ArrayUtilityTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\Utility; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Utility\ArrayUtility; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -42,10 +44,8 @@ public static function isJsonArrayReturnsExpectedValuesDataProcessor(): array ]; } - /** - * @test - * @dataProvider isJsonArrayReturnsExpectedValuesDataProcessor - */ + #[DataProvider('isJsonArrayReturnsExpectedValuesDataProcessor')] + #[Test] public function isJsonArrayReturnsExpectedValues($value, $expected): void { self::assertSame($expected, ArrayUtility::isJsonArray($value)); diff --git a/Tests/Unit/ViewHelpers/Be/IsActionEnabledViewHelperTest.php b/Tests/Unit/ViewHelpers/Be/IsActionEnabledViewHelperTest.php index 428b90000..95c00da8d 100644 --- a/Tests/Unit/ViewHelpers/Be/IsActionEnabledViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/Be/IsActionEnabledViewHelperTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\ViewHelpers; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\ViewHelpers\Be\IsActionEnabledViewHelper; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -64,10 +66,8 @@ public static function viewHelperReturnsExpectedResultDataProvider(): array ]; } - /** - * @test - * @dataProvider viewHelperReturnsExpectedResultDataProvider - */ + #[DataProvider('viewHelperReturnsExpectedResultDataProvider')] + #[Test] public function viewHelperReturnsExpectedResult(string $action, array $settings, bool $access, bool $expected): void { $viewHelper = new IsActionEnabledViewHelper(); diff --git a/Tests/Unit/ViewHelpers/Event/SimultaneousRegistrationsViewHelperTest.php b/Tests/Unit/ViewHelpers/Event/SimultaneousRegistrationsViewHelperTest.php index a4539ead2..3e41be5ca 100644 --- a/Tests/Unit/ViewHelpers/Event/SimultaneousRegistrationsViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/Event/SimultaneousRegistrationsViewHelperTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\ViewHelpers\Event; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Event; use DERHANSEN\SfEventMgt\ViewHelpers\Event\SimultaneousRegistrationsViewHelper; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -132,10 +134,8 @@ public static function simultaneousRegistrationsDataProvider(): array ]; } - /** - * @test - * @dataProvider simultaneousRegistrationsDataProvider - */ + #[DataProvider('simultaneousRegistrationsDataProvider')] + #[Test] public function viewHelperReturnsExpectedValues( int $maxParticipants, int $freePlaces, diff --git a/Tests/Unit/ViewHelpers/Format/ICalendarDateViewHelperTest.php b/Tests/Unit/ViewHelpers/Format/ICalendarDateViewHelperTest.php index a02eb7d77..10633156a 100644 --- a/Tests/Unit/ViewHelpers/Format/ICalendarDateViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/Format/ICalendarDateViewHelperTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\ViewHelpers; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DateTime; use DERHANSEN\SfEventMgt\ViewHelpers\Format\ICalendarDateViewHelper; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -33,10 +35,8 @@ public static function iCalendarDateDataProvider(): array ]; } - /** - * @test - * @dataProvider iCalendarDateDataProvider - */ + #[DataProvider('iCalendarDateDataProvider')] + #[Test] public function viewHelperReturnsExpectedValues(mixed $value, string $expected): void { $viewHelper = new ICalendarDateViewHelper(); @@ -45,9 +45,7 @@ public function viewHelperReturnsExpectedValues(mixed $value, string $expected): self::assertSame($expected, $actual); } - /** - * @test - */ + #[Test] public function viewHelperRendersChildrenIfNoValueGiven(): void { $viewHelper = $this->getMockBuilder(ICalendarDateViewHelper::class) diff --git a/Tests/Unit/ViewHelpers/Format/ICalendarDescriptionViewHelperTest.php b/Tests/Unit/ViewHelpers/Format/ICalendarDescriptionViewHelperTest.php index 953890358..9b109a779 100644 --- a/Tests/Unit/ViewHelpers/Format/ICalendarDescriptionViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/Format/ICalendarDescriptionViewHelperTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\ViewHelpers\Format; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\ViewHelpers\Format\ICalendarDescriptionViewHelper; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -57,10 +59,8 @@ public static function iCalendarDescriptionDataProvider(): array ]; } - /** - * @test - * @dataProvider iCalendarDescriptionDataProvider - */ + #[DataProvider('iCalendarDescriptionDataProvider')] + #[Test] public function viewHelperReturnsExpectedValues(string $value, int $substractChars, string $expected): void { $viewHelper = new ICalendarDescriptionViewHelper(); @@ -69,9 +69,7 @@ public function viewHelperReturnsExpectedValues(string $value, int $substractCha self::assertEquals($expected, $actual); } - /** - * @test - */ + #[Test] public function viewHelperRendersChildrenIfNoValueGiven(): void { $viewHelper = $this->getMockBuilder(ICalendarDescriptionViewHelper::class) diff --git a/Tests/Unit/ViewHelpers/PrefillViewHelperTest.php b/Tests/Unit/ViewHelpers/PrefillViewHelperTest.php index 6ef19fc22..694a98b19 100644 --- a/Tests/Unit/ViewHelpers/PrefillViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/PrefillViewHelperTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\ViewHelpers; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\ViewHelpers\PrefillViewHelper; use stdClass; use TYPO3\CMS\Extbase\Mvc\Request; @@ -22,9 +23,7 @@ */ class PrefillViewHelperTest extends UnitTestCase { - /** - * @test - */ + #[Test] public function viewHelperReturnsEmptyStringIfTsfeNotAvailabe(): void { $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock(); @@ -41,9 +40,7 @@ public function viewHelperReturnsEmptyStringIfTsfeNotAvailabe(): void self::assertSame('', $actual); } - /** - * @test - */ + #[Test] public function viewHelperReturnsCurrentFieldValueIfValueInParsedBodyAvailable(): void { $submittedData = [ @@ -70,9 +67,7 @@ public function viewHelperReturnsCurrentFieldValueIfValueInParsedBodyAvailable() self::assertSame('Torben', $actual); } - /** - * @test - */ + #[Test] public function viewHelperReturnsEmptyStringIfPrefillSettingsEmpty(): void { $submittedData = []; @@ -99,9 +94,7 @@ public function viewHelperReturnsEmptyStringIfPrefillSettingsEmpty(): void self::assertSame('', $actual); } - /** - * @test - */ + #[Test] public function viewHelperReturnsEmptyStringIfFieldNotFoundInPrefillSettings(): void { $submittedData = []; @@ -128,9 +121,7 @@ public function viewHelperReturnsEmptyStringIfFieldNotFoundInPrefillSettings(): self::assertSame('', $actual); } - /** - * @test - */ + #[Test] public function viewHelperReturnsEmptyStringIfFieldNotFoundInFeUser(): void { $GLOBALS['TSFE'] = new stdClass(); @@ -156,9 +147,7 @@ public function viewHelperReturnsEmptyStringIfFieldNotFoundInFeUser(): void self::assertSame('', $actual); } - /** - * @test - */ + #[Test] public function viewHelperReturnsFieldvalueIfFound(): void { $GLOBALS['TSFE'] = new stdClass(); @@ -185,9 +174,7 @@ public function viewHelperReturnsFieldvalueIfFound(): void self::assertSame('Doe', $actual); } - /** - * @test - */ + #[Test] public function viewHelperReturnsSubmittedValueIfValidationError(): void { $submittedData = [ diff --git a/Tests/Unit/ViewHelpers/Registration/Field/PrefillFieldViewHelperTest.php b/Tests/Unit/ViewHelpers/Registration/Field/PrefillFieldViewHelperTest.php index 636e946c0..7934a8775 100644 --- a/Tests/Unit/ViewHelpers/Registration/Field/PrefillFieldViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/Registration/Field/PrefillFieldViewHelperTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\ViewHelpers\Registration\Field; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; use DERHANSEN\SfEventMgt\Domain\Model\Registration\Field; use DERHANSEN\SfEventMgt\ViewHelpers\Registration\Field\PrefillFieldViewHelper; use TYPO3\CMS\Extbase\Mvc\ExtbaseRequestParameters; @@ -22,9 +24,7 @@ class PrefillFieldViewHelperTest extends UnitTestCase { - /** - * @test - */ + #[Test] public function viewHelperReturnsFieldDefaultValue(): void { $field = new Field(); @@ -43,9 +43,7 @@ public function viewHelperReturnsFieldDefaultValue(): void self::assertSame('Default', $viewHelper->render()); } - /** - * @test - */ + #[Test] public function viewHelperReturnsFieldFeUserValue(): void { $field = new Field(); @@ -93,10 +91,8 @@ public static function viewHelperReturnsSubmittedValueIfOriginalRequestExistData ]; } - /** - * @test - * @dataProvider viewHelperReturnsSubmittedValueIfOriginalRequestExistDataProvider - */ + #[DataProvider('viewHelperReturnsSubmittedValueIfOriginalRequestExistDataProvider')] + #[Test] public function viewHelperReturnsExpectedValueIfOriginalRequestExist( int $fieldUid, array $fieldValues, diff --git a/Tests/Unit/ViewHelpers/Registration/Field/PrefillMultiValueFieldViewHelperTest.php b/Tests/Unit/ViewHelpers/Registration/Field/PrefillMultiValueFieldViewHelperTest.php index aeb20c9bf..cc37fdf3c 100644 --- a/Tests/Unit/ViewHelpers/Registration/Field/PrefillMultiValueFieldViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/Registration/Field/PrefillMultiValueFieldViewHelperTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\ViewHelpers\Registration\Field; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Registration\Field; use DERHANSEN\SfEventMgt\ViewHelpers\Registration\Field\PrefillMultiValueFieldViewHelper; use TYPO3\CMS\Extbase\Mvc\ExtbaseRequestParameters; @@ -36,10 +38,8 @@ public static function viewHelperReturnsExpectedResultIfNoOriginalRequestDataPro ]; } - /** - * @test - * @dataProvider viewHelperReturnsExpectedResultIfNoOriginalRequestDataProvider - */ + #[DataProvider('viewHelperReturnsExpectedResultIfNoOriginalRequestDataProvider')] + #[Test] public function viewHelperReturnsExpectedResultIfNoOriginalRequest( string $defaultValue, string $currentValue, @@ -95,10 +95,8 @@ public static function viewHelperReturnsSubmittedValueIfOriginalRequestExistData ]; } - /** - * @test - * @dataProvider viewHelperReturnsSubmittedValueIfOriginalRequestExistDataProvider - */ + #[DataProvider('viewHelperReturnsSubmittedValueIfOriginalRequestExistDataProvider')] + #[Test] public function viewHelperReturnsExpectedValueIfOriginalRequestExist( int $submittedRegistrationFieldUid, int $registrationFieldUid, @@ -141,9 +139,7 @@ public function viewHelperReturnsExpectedValueIfOriginalRequestExist( self::assertEquals($expected, $viewHelper->render()); } - /** - * @test - */ + #[Test] public function viewHelperReturnsFalseIfOriginalRequestHasNoRegistrationFieldValues(): void { $field = $this->getMockBuilder(Field::class)->getMock(); diff --git a/Tests/Unit/ViewHelpers/Registration/IsRequiredFieldViewHelperTest.php b/Tests/Unit/ViewHelpers/Registration/IsRequiredFieldViewHelperTest.php index 9a2a6f045..035fba23e 100644 --- a/Tests/Unit/ViewHelpers/Registration/IsRequiredFieldViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/Registration/IsRequiredFieldViewHelperTest.php @@ -11,6 +11,7 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\ViewHelpers\Registration; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Registration\Field; use DERHANSEN\SfEventMgt\ViewHelpers\Registration\IsRequiredFieldViewHelper; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -20,9 +21,7 @@ */ class IsRequiredFieldViewHelperTest extends UnitTestCase { - /** - * @test - */ + #[Test] public function viewHelperDoesNotRenderThenChildWhenNoFieldnameGiven(): void { $viewHelper = $this->getAccessibleMock( @@ -45,9 +44,7 @@ public function viewHelperDoesNotRenderThenChildWhenNoFieldnameGiven(): void $viewHelper->render(); } - /** - * @test - */ + #[Test] public function viewHelperDoesNotRenderThenChildWhenFieldnameNotInSettings(): void { $viewHelper = $this->getAccessibleMock( @@ -70,9 +67,7 @@ public function viewHelperDoesNotRenderThenChildWhenFieldnameNotInSettings(): vo $viewHelper->render(); } - /** - * @test - */ + #[Test] public function viewHelperRendersThenChildWhenFieldnameInSettings(): void { $viewHelper = $this->getAccessibleMock( @@ -95,9 +90,7 @@ public function viewHelperRendersThenChildWhenFieldnameInSettings(): void $viewHelper->render(); } - /** - * @test - */ + #[Test] public function viewHelperRenderThenChildForDefaultRequiredFieldnames(): void { $viewHelper = $this->getAccessibleMock( @@ -120,9 +113,7 @@ public function viewHelperRenderThenChildForDefaultRequiredFieldnames(): void $viewHelper->render(); } - /** - * @test - */ + #[Test] public function viewHelperDoesNotRenderThenChildWhenNoRegistrationFieldGiven(): void { $viewHelper = $this->getAccessibleMock( @@ -141,9 +132,7 @@ public function viewHelperDoesNotRenderThenChildWhenNoRegistrationFieldGiven(): $viewHelper->render(); } - /** - * @test - */ + #[Test] public function viewHelperDoesNotRenderThenChildWhenOptionalRegistrationFieldGiven(): void { $viewHelper = $this->getAccessibleMock( @@ -166,9 +155,7 @@ public function viewHelperDoesNotRenderThenChildWhenOptionalRegistrationFieldGiv $viewHelper->render(); } - /** - * @test - */ + #[Test] public function viewHelperDoesRenderThenChildWhenRequiredRegistrationFieldGiven(): void { $viewHelper = $this->getAccessibleMock( diff --git a/Tests/Unit/ViewHelpers/Uri/OnlineCalendarViewHelperTest.php b/Tests/Unit/ViewHelpers/Uri/OnlineCalendarViewHelperTest.php index fcfb60822..daf07c8e0 100644 --- a/Tests/Unit/ViewHelpers/Uri/OnlineCalendarViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/Uri/OnlineCalendarViewHelperTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\ViewHelpers\Uri; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DateTime; use DERHANSEN\SfEventMgt\Domain\Model\Event; use DERHANSEN\SfEventMgt\Domain\Model\Location; @@ -65,10 +67,8 @@ public static function onlineCalendarViewHelperReturnsExpectedResultsDataProvide ]; } - /** - * @test - * @dataProvider onlineCalendarViewHelperReturnsExpectedResultsDataProvider - */ + #[DataProvider('onlineCalendarViewHelperReturnsExpectedResultsDataProvider')] + #[Test] public function onlineCalendarViewHelperReturnsExpectedResults(string $type, string $expected): void { $location = new Location(); @@ -96,9 +96,7 @@ function () { self::assertEquals($expected, $result); } - /** - * @test - */ + #[Test] public function defaultEnddateIsSetToEventsWithNoEnddate(): void { $location = new Location(); diff --git a/Tests/Unit/ViewHelpers/Validation/ErrorClassViewHelperTest.php b/Tests/Unit/ViewHelpers/Validation/ErrorClassViewHelperTest.php index 2f7d8f900..fe290ecfc 100644 --- a/Tests/Unit/ViewHelpers/Validation/ErrorClassViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/Validation/ErrorClassViewHelperTest.php @@ -11,6 +11,8 @@ namespace DERHANSEN\SfEventMgt\Tests\Unit\ViewHelpers; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use DERHANSEN\SfEventMgt\Domain\Model\Registration\Field; use DERHANSEN\SfEventMgt\ViewHelpers\Validation\ErrorClassViewHelper; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -73,13 +75,13 @@ public static function fieldnameDataProvider(): array } /** - * @test - * @dataProvider fieldnameDataProvider * @param array $validationErrors * @param string $fieldname * @param string $expected * @param string $errorClass */ + #[DataProvider('fieldnameDataProvider')] + #[Test] public function viewHelperReturnsExpectedStringForFieldname( array $validationErrors, string $fieldname, @@ -132,13 +134,13 @@ public static function registrationFieldDataProvider(): array } /** - * @test - * @dataProvider registrationFieldDataProvider * @param array $validationErrors * @param ?Field $registrationField * @param string $expected * @param string $errorClass */ + #[DataProvider('registrationFieldDataProvider')] + #[Test] public function viewHelperReturnsExpectedStringForRegistrationField( array $validationErrors, ?Field $registrationField,