From 51fc841de4f412b4866761b6ec299fba710ad9a3 Mon Sep 17 00:00:00 2001 From: Raymond Schouten Date: Thu, 30 May 2024 14:06:31 +0000 Subject: [PATCH] #255: Upgraded to PHPunit 10.5 --- composer.json | 2 +- phpunit.xml.dist | 19 +++++++++---------- tests/BirthdayTypeTest.php | 4 ++-- tests/BooleanToYesNoSubscriberTest.php | 18 +++++++++--------- tests/BooleanTypeTest.php | 26 +++++++++++--------------- tests/EntityTypeTest.php | 9 +++++---- tests/JsonSchemaSubscriberTest.php | 4 ++-- tests/UnstructuredTypeTest.php | 4 ++-- 8 files changed, 41 insertions(+), 45 deletions(-) diff --git a/composer.json b/composer.json index 8432699..7920b90 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "phpstan/phpstan-doctrine": "^1.4", "phpstan/phpstan-phpunit": "^1.4", "phpstan/phpstan-symfony": "^1.4", - "phpunit/phpunit": "^9.5", + "phpunit/phpunit": "^10.5", "rector/rector": "^1.1" }, "suggest": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 00333cf..e627563 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,18 +1,16 @@ + failOnWarning="true"> @@ -20,11 +18,12 @@ - + src - + diff --git a/tests/BirthdayTypeTest.php b/tests/BirthdayTypeTest.php index e64fab8..4b38231 100644 --- a/tests/BirthdayTypeTest.php +++ b/tests/BirthdayTypeTest.php @@ -23,13 +23,13 @@ namespace DarkWebDesign\SymfonyAddonFormTypes\Tests; use DarkWebDesign\SymfonyAddonFormTypes\BirthdayType; +use PHPUnit\Framework\Attributes\CoversClass; use Symfony\Component\Form\Test\TypeTestCase; /** - * @covers \DarkWebDesign\SymfonyAddonFormTypes\BirthdayType - * * @internal */ +#[CoversClass(BirthdayType::class)] class BirthdayTypeTest extends TypeTestCase { public function test(): void diff --git a/tests/BooleanToYesNoSubscriberTest.php b/tests/BooleanToYesNoSubscriberTest.php index 3056239..feec300 100644 --- a/tests/BooleanToYesNoSubscriberTest.php +++ b/tests/BooleanToYesNoSubscriberTest.php @@ -24,21 +24,21 @@ use DarkWebDesign\SymfonyAddonFormTypes\BooleanToYesNoSubscriber; use DarkWebDesign\SymfonyAddonFormTypes\BooleanType; +use DarkWebDesign\SymfonyAddonTransformers\BooleanToValueTransformer; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\UsesClass; use Symfony\Component\Form\Test\TypeTestCase; /** - * @covers \DarkWebDesign\SymfonyAddonFormTypes\BooleanToYesNoSubscriber - * - * @uses \DarkWebDesign\SymfonyAddonFormTypes\BooleanType - * @uses \DarkWebDesign\SymfonyAddonTransformers\BooleanToValueTransformer - * * @internal */ +#[CoversClass(BooleanToYesNoSubscriber::class)] +#[UsesClass(BooleanType::class)] +#[UsesClass(BooleanToValueTransformer::class)] class BooleanToYesNoSubscriberTest extends TypeTestCase { - /** - * @dataProvider provider - */ + #[DataProvider('provider')] public function test(?bool $value): void { $form = $this->factory->createBuilder() @@ -83,7 +83,7 @@ public function testDataNotArray(): void /** * @return array */ - public function provider(): array + public static function provider(): array { return [ 'true' => [true], diff --git a/tests/BooleanTypeTest.php b/tests/BooleanTypeTest.php index e40c955..99740dc 100644 --- a/tests/BooleanTypeTest.php +++ b/tests/BooleanTypeTest.php @@ -23,20 +23,20 @@ namespace DarkWebDesign\SymfonyAddonFormTypes\Tests; use DarkWebDesign\SymfonyAddonFormTypes\BooleanType; +use DarkWebDesign\SymfonyAddonTransformers\BooleanToValueTransformer; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\UsesClass; use Symfony\Component\Form\Test\TypeTestCase; /** - * @covers \DarkWebDesign\SymfonyAddonFormTypes\BooleanType - * - * @uses \DarkWebDesign\SymfonyAddonTransformers\BooleanToValueTransformer - * * @internal */ +#[CoversClass(BooleanType::class)] +#[UsesClass(BooleanToValueTransformer::class)] class BooleanTypeTest extends TypeTestCase { - /** - * @dataProvider providerValueTrueFalse - */ + #[DataProvider('providerValueTrueFalse')] public function test(mixed $valueTrue, mixed $valueFalse): void { $options = [ @@ -57,9 +57,7 @@ public function test(mixed $valueTrue, mixed $valueFalse): void $this->assertFalse($form->getData()); } - /** - * @dataProvider providerValueTrueFalse - */ + #[DataProvider('providerValueTrueFalse')] public function testInvalidValue(mixed $valueTrue, mixed $valueFalse): void { $options = [ @@ -74,9 +72,7 @@ public function testInvalidValue(mixed $valueTrue, mixed $valueFalse): void $this->assertNull($form->getData()); } - /** - * @dataProvider providerWidget - */ + #[DataProvider('providerWidget')] public function testWidget(string $widget, bool $expanded): void { $options = [ @@ -108,7 +104,7 @@ public function testHumanize(): void /** * @return array */ - public function providerValueTrueFalse(): array + public static function providerValueTrueFalse(): array { return [ 'true/false' => ['true', 'false'], @@ -123,7 +119,7 @@ public function providerValueTrueFalse(): array /** * @return array */ - public function providerWidget(): array + public static function providerWidget(): array { return [ 'choice' => ['choice', false], diff --git a/tests/EntityTypeTest.php b/tests/EntityTypeTest.php index 9237d6c..3280206 100644 --- a/tests/EntityTypeTest.php +++ b/tests/EntityTypeTest.php @@ -24,11 +24,14 @@ use DarkWebDesign\SymfonyAddonFormTypes\EntityType; use DarkWebDesign\SymfonyAddonFormTypes\Tests\Models\City; +use DarkWebDesign\SymfonyAddonTransformers\EntityToIdentifierTransformer; use Doctrine\ORM\EntityManager; use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\Mapping\ClassMetadata; use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectRepository; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\Form\Exception\RuntimeException; use Symfony\Component\Form\FormExtensionInterface; @@ -36,12 +39,10 @@ use Symfony\Component\Form\Test\TypeTestCase; /** - * @covers \DarkWebDesign\SymfonyAddonFormTypes\EntityType - * - * @uses \DarkWebDesign\SymfonyAddonTransformers\EntityToIdentifierTransformer - * * @internal */ +#[CoversClass(EntityType::class)] +#[UsesClass(EntityToIdentifierTransformer::class)] class EntityTypeTest extends TypeTestCase { private City $entity; diff --git a/tests/JsonSchemaSubscriberTest.php b/tests/JsonSchemaSubscriberTest.php index 58a6b77..86753bb 100644 --- a/tests/JsonSchemaSubscriberTest.php +++ b/tests/JsonSchemaSubscriberTest.php @@ -23,14 +23,14 @@ namespace DarkWebDesign\SymfonyAddonFormTypes\Tests; use DarkWebDesign\SymfonyAddonFormTypes\JsonSchemaSubscriber; +use PHPUnit\Framework\Attributes\CoversClass; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Test\TypeTestCase; /** - * @covers \DarkWebDesign\SymfonyAddonFormTypes\JsonSchemaSubscriber - * * @internal */ +#[CoversClass(JsonSchemaSubscriber::class)] class JsonSchemaSubscriberTest extends TypeTestCase { public function test(): void diff --git a/tests/UnstructuredTypeTest.php b/tests/UnstructuredTypeTest.php index 7a7917d..aee8b99 100644 --- a/tests/UnstructuredTypeTest.php +++ b/tests/UnstructuredTypeTest.php @@ -23,13 +23,13 @@ namespace DarkWebDesign\SymfonyAddonFormTypes\Tests; use DarkWebDesign\SymfonyAddonFormTypes\UnstructuredType; +use PHPUnit\Framework\Attributes\CoversClass; use Symfony\Component\Form\Test\TypeTestCase; /** - * @covers \DarkWebDesign\SymfonyAddonFormTypes\UnstructuredType - * * @internal */ +#[CoversClass(UnstructuredType::class)] class UnstructuredTypeTest extends TypeTestCase { public function testArray(): void