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 6, 2024
1 parent ecf7e9a commit cf27ccb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
17 changes: 5 additions & 12 deletions tests/Types/PhoneNumberTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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 @@ -19,9 +20,7 @@ private function getPhoneNumberType(): PhoneNumberType
return Type::getType('PhoneNumber');
}

/**
* @dataProvider providerConvertToDatabaseValue
*/
#[DataProvider('providerConvertToDatabaseValue')]
public function testConvertToDatabaseValue(?PhoneNumber $value, ?string $expectedValue): void
{
$type = $this->getPhoneNumberType();
Expand All @@ -39,9 +38,7 @@ public static function providerConvertToDatabaseValue(): array
];
}

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

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

/**
* @dataProvider providerConvertToPHPValueWithInvalidValue
*/
#[DataProvider('providerConvertToPHPValueWithInvalidValue')]
public function testConvertToPHPValueWithInvalidValue(mixed $value): void
{
$type = $this->getPhoneNumberType();
Expand Down
17 changes: 5 additions & 12 deletions tests/TypesFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Brick\PhoneNumber\PhoneNumber;
use Doctrine\DBAL\Connection;
use Doctrine\ORM\Tools\SchemaTool;
use PHPUnit\Framework\Attributes\Depends;

class TypesFunctionalTest extends AbstractFunctionalTestCase
{
Expand All @@ -30,9 +31,7 @@ public function testCreateSchema(): Connection
return $connection;
}

/**
* @depends testCreateSchema
*/
#[Depends('testCreateSchema')]
public function testSaveNull(Connection $connection): Connection
{
$em = self::createEntityManager($connection);
Expand All @@ -49,9 +48,7 @@ public function testSaveNull(Connection $connection): Connection
return $connection;
}

/**
* @depends testSaveNull
*/
#[Depends('testSaveNull')]
public function testLoadNull(Connection $connection): void
{
$em = self::createEntityManager($connection);
Expand All @@ -62,9 +59,7 @@ public function testLoadNull(Connection $connection): void
self::assertNull($entity->phoneNumber);
}

/**
* @depends testCreateSchema
*/
#[Depends('testCreateSchema')]
public function testSaveValues(Connection $connection): Connection
{
$em = self::createEntityManager($connection);
Expand All @@ -83,9 +78,7 @@ public function testSaveValues(Connection $connection): Connection
return $connection;
}

/**
* @depends testSaveValues
*/
#[Depends('testSaveValues')]
public function testLoadValues(Connection $connection): void
{
$em = self::createEntityManager($connection);
Expand Down

0 comments on commit cf27ccb

Please sign in to comment.