Skip to content

Commit

Permalink
[TASK] Use phpunit attributes over annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
derhansen committed Aug 30, 2024
1 parent f97b1a2 commit 9901330
Show file tree
Hide file tree
Showing 66 changed files with 857 additions and 1,993 deletions.
14 changes: 6 additions & 8 deletions Tests/Functional/Repository/CategoryRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
94 changes: 38 additions & 56 deletions Tests/Functional/Repository/EventRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -408,9 +401,8 @@ public function findSearchDemandedRecordsByStartDate(): void

/**
* Test if endDate restriction in demand works
*
* @test
*/
#[Test]
public function findSearchDemandedRecordsByEndDate(): void
{
$demand = new EventDemand();
Expand All @@ -427,9 +419,8 @@ public function findSearchDemandedRecordsByEndDate(): void

/**
* Test if title restriction in demand works
*
* @test
*/
#[Test]
public function findSearchDemandedRecordsByFieldTitle(): void
{
$demand = new EventDemand();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -565,9 +555,8 @@ public function findDemandedRecordsByOrderingIgnoresUnknownOrderField(): void

/**
* Test if limit restriction works
*
* @test
*/
#[Test]
public function findDemandedRecordsSetsLimit(): void
{
$demand = new EventDemand();
Expand All @@ -582,9 +571,8 @@ public function findDemandedRecordsSetsLimit(): void

/**
* Test if year restriction works
*
* @test
*/
#[Test]
public function findDemandedRecordsByYear(): void
{
$demand = new EventDemand();
Expand All @@ -599,9 +587,8 @@ public function findDemandedRecordsByYear(): void

/**
* Test if month restriction works
*
* @test
*/
#[Test]
public function findDemandedRecordsByMonth(): void
{
$demand = new EventDemand();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -653,9 +638,8 @@ public function findDemandedRecordsByMonthWithEnddateInGivenMonth(): void

/**
* Test if day restriction works
*
* @test
*/
#[Test]
public function findDemandedRecordsByDay(): void
{
$demand = new EventDemand();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions Tests/Functional/Repository/LocationRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,9 +37,7 @@ public function setUp(): void
$GLOBALS['TYPO3_REQUEST'] = $request;
}

/**
* @test
*/
#[Test]
public function startingPageIsIgnored(): void
{
$locations = $this->locationRepository->findAll();
Expand Down
Loading

0 comments on commit 9901330

Please sign in to comment.