From bf4f12a5a202da6cca41857f80e464aa8fef6780 Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Mon, 5 Feb 2024 23:51:05 +0100 Subject: [PATCH] Migrate to PHPUnit attributes --- tests/Types/DayOfWeekTypeTest.php | 17 +++++------------ tests/Types/DurationTypeTest.php | 17 +++++------------ tests/Types/InstantTypeTest.php | 13 ++++--------- tests/Types/LocalDateTimeTypeTest.php | 17 +++++------------ tests/Types/LocalDateTypeTest.php | 17 +++++------------ tests/Types/LocalTimeTypeTest.php | 17 +++++------------ tests/Types/PeriodTypeTest.php | 17 +++++------------ tests/TypesFunctionalTest.php | 17 +++++------------ 8 files changed, 39 insertions(+), 93 deletions(-) diff --git a/tests/Types/DayOfWeekTypeTest.php b/tests/Types/DayOfWeekTypeTest.php index 9a6584d..1eca2b0 100644 --- a/tests/Types/DayOfWeekTypeTest.php +++ b/tests/Types/DayOfWeekTypeTest.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use stdClass; use ValueError; @@ -22,9 +23,7 @@ private function getDayOfWeekType(): DayOfWeekType return Type::getType('DayOfWeek'); } - /** - * @dataProvider providerConvertToDatabaseValue - */ + #[DataProvider('providerConvertToDatabaseValue')] public function testConvertToDatabaseValue(?DayOfWeek $value, ?int $expectedValue): void { $type = $this->getDayOfWeekType(); @@ -47,9 +46,7 @@ public static function providerConvertToDatabaseValue(): array ]; } - /** - * @dataProvider providerConvertToDatabaseValueWithInvalidValue - */ + #[DataProvider('providerConvertToDatabaseValueWithInvalidValue')] public function testConvertToDatabaseValueWithInvalidValue($value): void { $type = $this->getDayOfWeekType(); @@ -71,9 +68,7 @@ public static function providerConvertToDatabaseValueWithInvalidValue(): array ]; } - /** - * @dataProvider providerConvertToPHPValue - */ + #[DataProvider('providerConvertToPHPValue')] public function testConvertToPHPValue($value, ?int $expectedDayOfWeekValue): void { $type = $this->getDayOfWeekType(); @@ -101,9 +96,7 @@ public static function providerConvertToPHPValue(): array ]; } - /** - * @dataProvider providerConvertToPHPValueWithInvalidValue - */ + #[DataProvider('providerConvertToPHPValueWithInvalidValue')] public function testConvertToPHPValueWithInvalidValue($value, string $expectedExceptionClass): void { $type = $this->getDayOfWeekType(); diff --git a/tests/Types/DurationTypeTest.php b/tests/Types/DurationTypeTest.php index 3884fd8..c01bcd0 100644 --- a/tests/Types/DurationTypeTest.php +++ b/tests/Types/DurationTypeTest.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use stdClass; @@ -22,9 +23,7 @@ private function getDurationType(): DurationType return Type::getType('Duration'); } - /** - * @dataProvider providerConvertToDatabaseValue - */ + #[DataProvider('providerConvertToDatabaseValue')] public function testConvertToDatabaseValue(?Duration $value, ?string $expectedValue): void { $type = $this->getDurationType(); @@ -41,9 +40,7 @@ public static function providerConvertToDatabaseValue(): array ]; } - /** - * @dataProvider providerConvertToDatabaseValueWithInvalidValue - */ + #[DataProvider('providerConvertToDatabaseValueWithInvalidValue')] public function testConvertToDatabaseValueWithInvalidValue($value): void { $type = $this->getDurationType(); @@ -65,9 +62,7 @@ public static function providerConvertToDatabaseValueWithInvalidValue(): array ]; } - /** - * @dataProvider providerConvertToPHPValue - */ + #[DataProvider('providerConvertToPHPValue')] public function testConvertToPHPValue($value, ?string $expectedDurationString): void { $type = $this->getDurationType(); @@ -89,9 +84,7 @@ public static function providerConvertToPHPValue(): array ]; } - /** - * @dataProvider providerConvertToPHPValueWithInvalidValue - */ + #[DataProvider('providerConvertToPHPValueWithInvalidValue')] public function testConvertToPHPValueWithInvalidValue($value, string $expectedExceptionClass): void { $type = $this->getDurationType(); diff --git a/tests/Types/InstantTypeTest.php b/tests/Types/InstantTypeTest.php index 0e944bb..be180d3 100644 --- a/tests/Types/InstantTypeTest.php +++ b/tests/Types/InstantTypeTest.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use stdClass; @@ -21,9 +22,7 @@ private function getInstantType(): InstantType return Type::getType('Instant'); } - /** - * @dataProvider providerConvertToDatabaseValue - */ + #[DataProvider('providerConvertToDatabaseValue')] public function testConvertToDatabaseValue(?Instant $value, ?int $expectedValue): void { $type = $this->getInstantType(); @@ -41,9 +40,7 @@ public static function providerConvertToDatabaseValue(): array ]; } - /** - * @dataProvider providerConvertToDatabaseValueWithInvalidValue - */ + #[DataProvider('providerConvertToDatabaseValueWithInvalidValue')] public function testConvertToDatabaseValueWithInvalidValue($value): void { $type = $this->getInstantType(); @@ -65,9 +62,7 @@ public static function providerConvertToDatabaseValueWithInvalidValue(): array ]; } - /** - * @dataProvider providerConvertToPHPValue - */ + #[DataProvider('providerConvertToPHPValue')] public function testConvertToPHPValue($value, ?int $expectedEpochSecond): void { $type = $this->getInstantType(); diff --git a/tests/Types/LocalDateTimeTypeTest.php b/tests/Types/LocalDateTimeTypeTest.php index 2ba5b2a..dcc0043 100644 --- a/tests/Types/LocalDateTimeTypeTest.php +++ b/tests/Types/LocalDateTimeTypeTest.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use stdClass; @@ -22,9 +23,7 @@ private function getLocalDateTimeType(): LocalDateTimeType return Type::getType('LocalDateTime'); } - /** - * @dataProvider providerConvertToDatabaseValue - */ + #[DataProvider('providerConvertToDatabaseValue')] public function testConvertToDatabaseValue(?LocalDateTime $value, ?string $expectedValue): void { $type = $this->getLocalDateTimeType(); @@ -43,9 +42,7 @@ public static function providerConvertToDatabaseValue(): array ]; } - /** - * @dataProvider providerConvertToDatabaseValueWithInvalidValue - */ + #[DataProvider('providerConvertToDatabaseValueWithInvalidValue')] public function testConvertToDatabaseValueWithInvalidValue($value): void { $type = $this->getLocalDateTimeType(); @@ -68,9 +65,7 @@ public static function providerConvertToDatabaseValueWithInvalidValue(): array ]; } - /** - * @dataProvider providerConvertToPHPValue - */ + #[DataProvider('providerConvertToPHPValue')] public function testConvertToPHPValue($value, ?string $expectedLocalDateTimeString): void { $type = $this->getLocalDateTimeType(); @@ -95,9 +90,7 @@ public static function providerConvertToPHPValue(): array ]; } - /** - * @dataProvider providerConvertToPHPValueWithInvalidValue - */ + #[DataProvider('providerConvertToPHPValueWithInvalidValue')] public function testConvertToPHPValueWithInvalidValue($value, string $expectedExceptionClass): void { $type = $this->getLocalDateTimeType(); diff --git a/tests/Types/LocalDateTypeTest.php b/tests/Types/LocalDateTypeTest.php index 459a323..7a59709 100644 --- a/tests/Types/LocalDateTypeTest.php +++ b/tests/Types/LocalDateTypeTest.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use stdClass; @@ -22,9 +23,7 @@ private function getLocalDateType(): LocalDateType return Type::getType('LocalDate'); } - /** - * @dataProvider providerConvertToDatabaseValue - */ + #[DataProvider('providerConvertToDatabaseValue')] public function testConvertToDatabaseValue(?LocalDate $value, ?string $expectedValue): void { $type = $this->getLocalDateType(); @@ -41,9 +40,7 @@ public static function providerConvertToDatabaseValue(): array ]; } - /** - * @dataProvider providerConvertToDatabaseValueWithInvalidValue - */ + #[DataProvider('providerConvertToDatabaseValueWithInvalidValue')] public function testConvertToDatabaseValueWithInvalidValue($value): void { $type = $this->getLocalDateType(); @@ -65,9 +62,7 @@ public static function providerConvertToDatabaseValueWithInvalidValue(): array ]; } - /** - * @dataProvider providerConvertToPHPValue - */ + #[DataProvider('providerConvertToPHPValue')] public function testConvertToPHPValue($value, ?string $expectedLocalDateString): void { $type = $this->getLocalDateType(); @@ -89,9 +84,7 @@ public static function providerConvertToPHPValue(): array ]; } - /** - * @dataProvider providerConvertToPHPValueWithInvalidValue - */ + #[DataProvider('providerConvertToPHPValueWithInvalidValue')] public function testConvertToPHPValueWithInvalidValue($value, string $expectedExceptionClass): void { $type = $this->getLocalDateType(); diff --git a/tests/Types/LocalTimeTypeTest.php b/tests/Types/LocalTimeTypeTest.php index 76cba60..c2cc2dd 100644 --- a/tests/Types/LocalTimeTypeTest.php +++ b/tests/Types/LocalTimeTypeTest.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use stdClass; @@ -22,9 +23,7 @@ private function getLocalTimeType(): LocalTimeType return Type::getType('LocalTime'); } - /** - * @dataProvider providerConvertToDatabaseValue - */ + #[DataProvider('providerConvertToDatabaseValue')] public function testConvertToDatabaseValue(?LocalTime $value, ?string $expectedValue): void { $type = $this->getLocalTimeType(); @@ -43,9 +42,7 @@ public static function providerConvertToDatabaseValue(): array ]; } - /** - * @dataProvider providerConvertToDatabaseValueWithInvalidValue - */ + #[DataProvider('providerConvertToDatabaseValueWithInvalidValue')] public function testConvertToDatabaseValueWithInvalidValue($value): void { $type = $this->getLocalTimeType(); @@ -67,9 +64,7 @@ public static function providerConvertToDatabaseValueWithInvalidValue(): array ]; } - /** - * @dataProvider providerConvertToPHPValue - */ + #[DataProvider('providerConvertToPHPValue')] public function testConvertToPHPValue($value, ?string $expectedLocalTimeString): void { $type = $this->getLocalTimeType(); @@ -92,9 +87,7 @@ public static function providerConvertToPHPValue(): array ]; } - /** - * @dataProvider providerConvertToPHPValueWithInvalidValue - */ + #[DataProvider('providerConvertToPHPValueWithInvalidValue')] public function testConvertToPHPValueWithInvalidValue($value, string $expectedExceptionClass): void { $type = $this->getLocalTimeType(); diff --git a/tests/Types/PeriodTypeTest.php b/tests/Types/PeriodTypeTest.php index 13d5ec3..54aebf4 100644 --- a/tests/Types/PeriodTypeTest.php +++ b/tests/Types/PeriodTypeTest.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use stdClass; @@ -22,9 +23,7 @@ private function getPeriodType(): PeriodType return Type::getType('Period'); } - /** - * @dataProvider providerConvertToDatabaseValue - */ + #[DataProvider('providerConvertToDatabaseValue')] public function testConvertToDatabaseValue(?Period $value, ?string $expectedValue): void { $type = $this->getPeriodType(); @@ -41,9 +40,7 @@ public static function providerConvertToDatabaseValue(): array ]; } - /** - * @dataProvider providerConvertToDatabaseValueWithInvalidValue - */ + #[DataProvider('providerConvertToDatabaseValueWithInvalidValue')] public function testConvertToDatabaseValueWithInvalidValue($value): void { $type = $this->getPeriodType(); @@ -65,9 +62,7 @@ public static function providerConvertToDatabaseValueWithInvalidValue(): array ]; } - /** - * @dataProvider providerConvertToPHPValue - */ + #[DataProvider('providerConvertToPHPValue')] public function testConvertToPHPValue($value, ?string $expectedPeriodString): void { $type = $this->getPeriodType(); @@ -89,9 +84,7 @@ public static function providerConvertToPHPValue(): array ]; } - /** - * @dataProvider providerConvertToPHPValueWithInvalidValue - */ + #[DataProvider('providerConvertToPHPValueWithInvalidValue')] public function testConvertToPHPValueWithInvalidValue($value, string $expectedExceptionClass): void { $type = $this->getPeriodType(); diff --git a/tests/TypesFunctionalTest.php b/tests/TypesFunctionalTest.php index d34a413..9f1604f 100644 --- a/tests/TypesFunctionalTest.php +++ b/tests/TypesFunctionalTest.php @@ -14,6 +14,7 @@ use Brick\DateTime\Period; use Doctrine\DBAL\Connection; use Doctrine\ORM\Tools\SchemaTool; +use PHPUnit\Framework\Attributes\Depends; class TypesFunctionalTest extends AbstractFunctionalTestCase { @@ -42,9 +43,7 @@ public function testCreateSchema(): Connection return $connection; } - /** - * @depends testCreateSchema - */ + #[Depends('testCreateSchema')] public function testSaveNull(Connection $connection): Connection { $em = self::createEntityManager($connection); @@ -61,9 +60,7 @@ public function testSaveNull(Connection $connection): Connection return $connection; } - /** - * @depends testSaveNull - */ + #[Depends('testSaveNull')] public function testLoadNull(Connection $connection): void { $em = self::createEntityManager($connection); @@ -81,9 +78,7 @@ public function testLoadNull(Connection $connection): void self::assertNull($entity->period); } - /** - * @depends testCreateSchema - */ + #[Depends('testCreateSchema')] public function testSaveValues(Connection $connection): Connection { $em = self::createEntityManager($connection); @@ -108,9 +103,7 @@ public function testSaveValues(Connection $connection): Connection return $connection; } - /** - * @depends testSaveValues - */ + #[Depends('testSaveValues')] public function testLoadValues(Connection $connection): void { $em = self::createEntityManager($connection);