Skip to content

Commit

Permalink
Migrate to PHPUnit attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Feb 5, 2024
1 parent 674580b commit bf4f12a
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 93 deletions.
17 changes: 5 additions & 12 deletions tests/Types/DayOfWeekTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -47,9 +46,7 @@ public static function providerConvertToDatabaseValue(): array
];
}

/**
* @dataProvider providerConvertToDatabaseValueWithInvalidValue
*/
#[DataProvider('providerConvertToDatabaseValueWithInvalidValue')]
public function testConvertToDatabaseValueWithInvalidValue($value): void
{
$type = $this->getDayOfWeekType();
Expand All @@ -71,9 +68,7 @@ public static function providerConvertToDatabaseValueWithInvalidValue(): array
];
}

/**
* @dataProvider providerConvertToPHPValue
*/
#[DataProvider('providerConvertToPHPValue')]
public function testConvertToPHPValue($value, ?int $expectedDayOfWeekValue): void
{
$type = $this->getDayOfWeekType();
Expand Down Expand Up @@ -101,9 +96,7 @@ public static function providerConvertToPHPValue(): array
];
}

/**
* @dataProvider providerConvertToPHPValueWithInvalidValue
*/
#[DataProvider('providerConvertToPHPValueWithInvalidValue')]
public function testConvertToPHPValueWithInvalidValue($value, string $expectedExceptionClass): void
{
$type = $this->getDayOfWeekType();
Expand Down
17 changes: 5 additions & 12 deletions tests/Types/DurationTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand All @@ -41,9 +40,7 @@ public static function providerConvertToDatabaseValue(): array
];
}

/**
* @dataProvider providerConvertToDatabaseValueWithInvalidValue
*/
#[DataProvider('providerConvertToDatabaseValueWithInvalidValue')]
public function testConvertToDatabaseValueWithInvalidValue($value): void
{
$type = $this->getDurationType();
Expand All @@ -65,9 +62,7 @@ public static function providerConvertToDatabaseValueWithInvalidValue(): array
];
}

/**
* @dataProvider providerConvertToPHPValue
*/
#[DataProvider('providerConvertToPHPValue')]
public function testConvertToPHPValue($value, ?string $expectedDurationString): void
{
$type = $this->getDurationType();
Expand All @@ -89,9 +84,7 @@ public static function providerConvertToPHPValue(): array
];
}

/**
* @dataProvider providerConvertToPHPValueWithInvalidValue
*/
#[DataProvider('providerConvertToPHPValueWithInvalidValue')]
public function testConvertToPHPValueWithInvalidValue($value, string $expectedExceptionClass): void
{
$type = $this->getDurationType();
Expand Down
13 changes: 4 additions & 9 deletions tests/Types/InstantTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand All @@ -41,9 +40,7 @@ public static function providerConvertToDatabaseValue(): array
];
}

/**
* @dataProvider providerConvertToDatabaseValueWithInvalidValue
*/
#[DataProvider('providerConvertToDatabaseValueWithInvalidValue')]
public function testConvertToDatabaseValueWithInvalidValue($value): void
{
$type = $this->getInstantType();
Expand All @@ -65,9 +62,7 @@ public static function providerConvertToDatabaseValueWithInvalidValue(): array
];
}

/**
* @dataProvider providerConvertToPHPValue
*/
#[DataProvider('providerConvertToPHPValue')]
public function testConvertToPHPValue($value, ?int $expectedEpochSecond): void
{
$type = $this->getInstantType();
Expand Down
17 changes: 5 additions & 12 deletions tests/Types/LocalDateTimeTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand All @@ -43,9 +42,7 @@ public static function providerConvertToDatabaseValue(): array
];
}

/**
* @dataProvider providerConvertToDatabaseValueWithInvalidValue
*/
#[DataProvider('providerConvertToDatabaseValueWithInvalidValue')]
public function testConvertToDatabaseValueWithInvalidValue($value): void
{
$type = $this->getLocalDateTimeType();
Expand All @@ -68,9 +65,7 @@ public static function providerConvertToDatabaseValueWithInvalidValue(): array
];
}

/**
* @dataProvider providerConvertToPHPValue
*/
#[DataProvider('providerConvertToPHPValue')]
public function testConvertToPHPValue($value, ?string $expectedLocalDateTimeString): void
{
$type = $this->getLocalDateTimeType();
Expand All @@ -95,9 +90,7 @@ public static function providerConvertToPHPValue(): array
];
}

/**
* @dataProvider providerConvertToPHPValueWithInvalidValue
*/
#[DataProvider('providerConvertToPHPValueWithInvalidValue')]
public function testConvertToPHPValueWithInvalidValue($value, string $expectedExceptionClass): void
{
$type = $this->getLocalDateTimeType();
Expand Down
17 changes: 5 additions & 12 deletions tests/Types/LocalDateTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand All @@ -41,9 +40,7 @@ public static function providerConvertToDatabaseValue(): array
];
}

/**
* @dataProvider providerConvertToDatabaseValueWithInvalidValue
*/
#[DataProvider('providerConvertToDatabaseValueWithInvalidValue')]
public function testConvertToDatabaseValueWithInvalidValue($value): void
{
$type = $this->getLocalDateType();
Expand All @@ -65,9 +62,7 @@ public static function providerConvertToDatabaseValueWithInvalidValue(): array
];
}

/**
* @dataProvider providerConvertToPHPValue
*/
#[DataProvider('providerConvertToPHPValue')]
public function testConvertToPHPValue($value, ?string $expectedLocalDateString): void
{
$type = $this->getLocalDateType();
Expand All @@ -89,9 +84,7 @@ public static function providerConvertToPHPValue(): array
];
}

/**
* @dataProvider providerConvertToPHPValueWithInvalidValue
*/
#[DataProvider('providerConvertToPHPValueWithInvalidValue')]
public function testConvertToPHPValueWithInvalidValue($value, string $expectedExceptionClass): void
{
$type = $this->getLocalDateType();
Expand Down
17 changes: 5 additions & 12 deletions tests/Types/LocalTimeTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand All @@ -43,9 +42,7 @@ public static function providerConvertToDatabaseValue(): array
];
}

/**
* @dataProvider providerConvertToDatabaseValueWithInvalidValue
*/
#[DataProvider('providerConvertToDatabaseValueWithInvalidValue')]
public function testConvertToDatabaseValueWithInvalidValue($value): void
{
$type = $this->getLocalTimeType();
Expand All @@ -67,9 +64,7 @@ public static function providerConvertToDatabaseValueWithInvalidValue(): array
];
}

/**
* @dataProvider providerConvertToPHPValue
*/
#[DataProvider('providerConvertToPHPValue')]
public function testConvertToPHPValue($value, ?string $expectedLocalTimeString): void
{
$type = $this->getLocalTimeType();
Expand All @@ -92,9 +87,7 @@ public static function providerConvertToPHPValue(): array
];
}

/**
* @dataProvider providerConvertToPHPValueWithInvalidValue
*/
#[DataProvider('providerConvertToPHPValueWithInvalidValue')]
public function testConvertToPHPValueWithInvalidValue($value, string $expectedExceptionClass): void
{
$type = $this->getLocalTimeType();
Expand Down
17 changes: 5 additions & 12 deletions tests/Types/PeriodTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand All @@ -41,9 +40,7 @@ public static function providerConvertToDatabaseValue(): array
];
}

/**
* @dataProvider providerConvertToDatabaseValueWithInvalidValue
*/
#[DataProvider('providerConvertToDatabaseValueWithInvalidValue')]
public function testConvertToDatabaseValueWithInvalidValue($value): void
{
$type = $this->getPeriodType();
Expand All @@ -65,9 +62,7 @@ public static function providerConvertToDatabaseValueWithInvalidValue(): array
];
}

/**
* @dataProvider providerConvertToPHPValue
*/
#[DataProvider('providerConvertToPHPValue')]
public function testConvertToPHPValue($value, ?string $expectedPeriodString): void
{
$type = $this->getPeriodType();
Expand All @@ -89,9 +84,7 @@ public static function providerConvertToPHPValue(): array
];
}

/**
* @dataProvider providerConvertToPHPValueWithInvalidValue
*/
#[DataProvider('providerConvertToPHPValueWithInvalidValue')]
public function testConvertToPHPValueWithInvalidValue($value, string $expectedExceptionClass): void
{
$type = $this->getPeriodType();
Expand Down
Loading

0 comments on commit bf4f12a

Please sign in to comment.