From: =?utf-8?q?David_Pr=C3=A9vot?= <taffit@debian.org>
Date: Sat, 5 Apr 2025 10:48:15 +0200
Subject: Modernize PHPUnit syntax

---
 tests/Constraints/BaseTestCase.php                  |  5 +++++
 tests/Constraints/CoerciveTest.php                  |  5 +++--
 tests/Constraints/DefaultPropertiesTest.php         | 13 ++++---------
 tests/Constraints/FactoryTest.php                   |  9 +++------
 tests/Constraints/FormatTest.php                    | 13 ++++---------
 tests/Constraints/SchemaValidationTest.php          |  9 +++------
 tests/Constraints/TypeTest.php                      |  9 +++------
 tests/Drafts/Draft3Test.php                         |  2 ++
 tests/Entity/JsonPointerTest.php                    |  5 ++---
 tests/JsonSchemaTestSuiteTest.php                   |  2 ++
 tests/RefTest.php                                   |  3 ++-
 tests/Rfc3339Test.php                               |  9 +++------
 tests/Tool/DeepComparerTest.php                     |  9 +++------
 .../Validator/RelativeReferenceValidatorTest.php    |  5 +++--
 tests/Tool/Validator/UriValidatorTest.php           |  5 +++--
 tests/Uri/UriRetrieverTest.php                      | 21 ++++++---------------
 16 files changed, 51 insertions(+), 73 deletions(-)

diff --git a/tests/Constraints/BaseTestCase.php b/tests/Constraints/BaseTestCase.php
index 63b63a4..7c96c50 100644
--- a/tests/Constraints/BaseTestCase.php
+++ b/tests/Constraints/BaseTestCase.php
@@ -10,6 +10,7 @@ use JsonSchema\Constraints\Factory;
 use JsonSchema\SchemaStorage;
 use JsonSchema\Uri\UriResolver;
 use JsonSchema\Validator;
+use PHPUnit\Framework\Attributes\DataProvider;
 
 abstract class BaseTestCase extends VeryBaseTestCase
 {
@@ -21,6 +22,7 @@ abstract class BaseTestCase extends VeryBaseTestCase
      *
      * @param ?int-mask-of<Constraint::CHECK_MODE_*> $checkMode
      */
+    #[DataProvider('getInvalidTests')]
     public function testInvalidCases(string $input, string $schema, ?int $checkMode = Constraint::CHECK_MODE_NORMAL, array $errors = []): void
     {
         $checkMode = $checkMode ?? Constraint::CHECK_MODE_NORMAL;
@@ -53,6 +55,7 @@ abstract class BaseTestCase extends VeryBaseTestCase
      *
      * @param ?int-mask-of<Constraint::CHECK_MODE_*> $checkMode
      */
+    #[DataProvider('getInvalidForAssocTests')]
     public function testInvalidCasesUsingAssoc(string $input, string $schema, ?int $checkMode = Constraint::CHECK_MODE_TYPE_CAST, array $errors = []): void
     {
         $checkMode = $checkMode ?? Constraint::CHECK_MODE_TYPE_CAST;
@@ -88,6 +91,7 @@ abstract class BaseTestCase extends VeryBaseTestCase
      *
      * @param ?int-mask-of<Constraint::CHECK_MODE_*> $checkMode
      */
+    #[DataProvider('getValidTests')]
     public function testValidCases(string $input, string $schema, ?int $checkMode = Constraint::CHECK_MODE_NORMAL): void
     {
         if ($this->validateSchema) {
@@ -114,6 +118,7 @@ abstract class BaseTestCase extends VeryBaseTestCase
      *
      * @param ?int-mask-of<Constraint::CHECK_MODE_*> $checkMode
      */
+    #[DataProvider('getValidForAssocTests')]
     public function testValidCasesUsingAssoc(string $input, string $schema, ?int $checkMode = Constraint::CHECK_MODE_TYPE_CAST): void
     {
         if ($this->validateSchema) {
diff --git a/tests/Constraints/CoerciveTest.php b/tests/Constraints/CoerciveTest.php
index 47dcc07..87251d7 100644
--- a/tests/Constraints/CoerciveTest.php
+++ b/tests/Constraints/CoerciveTest.php
@@ -8,6 +8,7 @@ use JsonSchema\Constraints\Constraint;
 use JsonSchema\Constraints\Factory;
 use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
 use JsonSchema\Validator;
+use PHPUnit\Framework\Attributes\DataProvider;
 
 class CoerciveTest extends VeryBaseTestCase
 {
@@ -184,7 +185,7 @@ class CoerciveTest extends VeryBaseTestCase
         return $tests;
     }
 
-    /** @dataProvider dataCoerceCases **/
+    #[DataProvider('dataCoerceCases')]
     public function testCoerceCases($schema, $data, $startType, $endType, $endValue, $valid, $extraFlags = 0, $assoc = false): void
     {
         $validator = new Validator($this->factory);
@@ -226,7 +227,7 @@ class CoerciveTest extends VeryBaseTestCase
         }
     }
 
-    /** @dataProvider dataCoerceCases **/
+    #[DataProvider('dataCoerceCases')]
     public function testCoerceCasesUsingAssoc($schema, $data, $startType, $endType, $endValue, $valid, $early = false): void
     {
         $this->testCoerceCases($schema, $data, $startType, $endType, $endValue, $valid, $early, true);
diff --git a/tests/Constraints/DefaultPropertiesTest.php b/tests/Constraints/DefaultPropertiesTest.php
index e43b980..084b2fd 100644
--- a/tests/Constraints/DefaultPropertiesTest.php
+++ b/tests/Constraints/DefaultPropertiesTest.php
@@ -8,6 +8,7 @@ use JsonSchema\Constraints\Constraint;
 use JsonSchema\Constraints\Factory;
 use JsonSchema\SchemaStorage;
 use JsonSchema\Validator;
+use PHPUnit\Framework\Attributes\DataProvider;
 
 class DefaultPropertiesTest extends VeryBaseTestCase
 {
@@ -162,9 +163,7 @@ class DefaultPropertiesTest extends VeryBaseTestCase
         ];
     }
 
-    /**
-     * @dataProvider getValidTests
-     */
+    #[DataProvider('getValidTests')]
     public function testValidCases($input, $schema, $expectOutput = null, $checkMode = 0): void
     {
         if (is_string($input)) {
@@ -189,9 +188,7 @@ class DefaultPropertiesTest extends VeryBaseTestCase
         }
     }
 
-    /**
-     * @dataProvider getValidTests
-     */
+    #[DataProvider('getValidTests')]
     public function testValidCasesUsingAssoc($input, $schema, $expectOutput = null, $checkMode = 0): void
     {
         $input = json_decode($input, true);
@@ -200,9 +197,7 @@ class DefaultPropertiesTest extends VeryBaseTestCase
         self::testValidCases($input, $schema, $expectOutput, $checkMode);
     }
 
-    /**
-     * @dataProvider getValidTests
-     */
+    #[DataProvider('getValidTests')]
     public function testValidCasesUsingAssocWithoutTypeCast($input, $schema, $expectOutput = null, $checkMode = 0): void
     {
         $input = json_decode($input, true);
diff --git a/tests/Constraints/FactoryTest.php b/tests/Constraints/FactoryTest.php
index 0ff6e92..55892e0 100644
--- a/tests/Constraints/FactoryTest.php
+++ b/tests/Constraints/FactoryTest.php
@@ -10,6 +10,7 @@ use JsonSchema\Constraints\ConstraintInterface;
 use JsonSchema\Constraints\Factory;
 use JsonSchema\Entity\JsonPointer;
 use JsonSchema\Exception\InvalidArgumentException;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class MyBadConstraint
@@ -25,9 +26,7 @@ class MyStringConstraint extends Constraint
 
 class FactoryTest extends TestCase
 {
-    /**
-     * @dataProvider constraintNameProvider
-     */
+    #[DataProvider('constraintNameProvider')]
     public function testCreateInstanceForConstraintName(string $constraintName, string $expectedClass): void
     {
         $factory = new Factory();
@@ -52,9 +51,7 @@ class FactoryTest extends TestCase
         yield 'Schema' => ['schema', Constraints\SchemaConstraint::class];
     }
 
-    /**
-     * @dataProvider invalidConstraintNameProvider
-     */
+    #[DataProvider('invalidConstraintNameProvider')]
     public function testExceptionWhenCreateInstanceForInvalidConstraintName(string $constraintName): void
     {
         $factory = new Factory();
diff --git a/tests/Constraints/FormatTest.php b/tests/Constraints/FormatTest.php
index 7247105..67ef74b 100644
--- a/tests/Constraints/FormatTest.php
+++ b/tests/Constraints/FormatTest.php
@@ -7,6 +7,7 @@ namespace JsonSchema\Tests\Constraints;
 use JsonSchema\Constraints\Constraint;
 use JsonSchema\Constraints\Factory;
 use JsonSchema\Constraints\FormatConstraint;
+use PHPUnit\Framework\Attributes\DataProvider;
 
 class FormatTest extends BaseTestCase
 {
@@ -50,9 +51,7 @@ class FormatTest extends BaseTestCase
         $this->assertEmpty($validator->getErrors());
     }
 
-    /**
-     * @dataProvider getValidFormats
-     */
+    #[DataProvider('getValidFormats')]
     public function testValidFormat($string, $format): void
     {
         $validator = new FormatConstraint();
@@ -63,9 +62,7 @@ class FormatTest extends BaseTestCase
         $this->assertEmpty($validator->getErrors());
     }
 
-    /**
-     * @dataProvider getInvalidFormats
-     */
+    #[DataProvider('getInvalidFormats')]
     public function testInvalidFormat($string, $format): void
     {
         $validator = new FormatConstraint();
@@ -76,9 +73,7 @@ class FormatTest extends BaseTestCase
         $this->assertCount(1, $validator->getErrors(), 'Expected 1 error');
     }
 
-    /**
-     * @dataProvider getInvalidFormats
-     */
+    #[DataProvider('getInvalidFormats')]
     public function testDisabledFormat($string, $format): void
     {
         $factory = new Factory();
diff --git a/tests/Constraints/SchemaValidationTest.php b/tests/Constraints/SchemaValidationTest.php
index e7b4196..b4c92ef 100644
--- a/tests/Constraints/SchemaValidationTest.php
+++ b/tests/Constraints/SchemaValidationTest.php
@@ -6,6 +6,7 @@ namespace JsonSchema\Tests\Constraints;
 
 use JsonSchema\Constraints\Constraint;
 use JsonSchema\Validator;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class SchemaValidationTest extends TestCase
@@ -56,9 +57,7 @@ class SchemaValidationTest extends TestCase
         ];
     }
 
-    /**
-     * @dataProvider getInvalidTests
-     */
+    #[DataProvider('getInvalidTests')]
     public function testInvalidCases($schema): void
     {
         $input = json_decode('{"propertyOne":"valueOne"}');
@@ -77,9 +76,7 @@ class SchemaValidationTest extends TestCase
         }
     }
 
-    /**
-     * @dataProvider getValidTests
-     */
+    #[DataProvider('getValidTests')]
     public function testValidCases($schema): void
     {
         $input = json_decode('{"propertyOne":"valueOne"}');
diff --git a/tests/Constraints/TypeTest.php b/tests/Constraints/TypeTest.php
index 8292b9b..d9bf404 100644
--- a/tests/Constraints/TypeTest.php
+++ b/tests/Constraints/TypeTest.php
@@ -6,6 +6,7 @@ namespace JsonSchema\Tests\Constraints;
 
 use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
 use JsonSchema\Constraints\TypeConstraint;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class TypeTest extends TestCase
@@ -29,9 +30,7 @@ class TypeTest extends TestCase
         ];
     }
 
-    /**
-     * @dataProvider provideIndefiniteArticlesForTypes
-     */
+    #[DataProvider('provideIndefiniteArticlesForTypes')]
     public function testIndefiniteArticleForTypeInTypeCheckErrorMessage($type, $wording, $value = null, $label = 'NULL'): void
     {
         $constraint = new TypeConstraint();
@@ -88,9 +87,7 @@ class TypeTest extends TestCase
         return $wordings;
     }
 
-    /**
-     * @dataProvider validNameWordingDataProvider
-     */
+    #[DataProvider('validNameWordingDataProvider')]
     public function testValidateTypeNameWording($nameWording): void
     {
         $t = new TypeConstraint();
diff --git a/tests/Drafts/Draft3Test.php b/tests/Drafts/Draft3Test.php
index 2d1202e..91b593f 100644
--- a/tests/Drafts/Draft3Test.php
+++ b/tests/Drafts/Draft3Test.php
@@ -7,6 +7,7 @@ namespace JsonSchema\Tests\Drafts;
 use JsonSchema\Constraints\Factory;
 use JsonSchema\SchemaStorage;
 use JsonSchema\Validator;
+use PHPUnit\Framework\Attributes\DataProvider;
 
 class Draft3Test extends BaseDraftTestCase
 {
@@ -23,6 +24,7 @@ class Draft3Test extends BaseDraftTestCase
      * @param mixed $data
      * @dataProvider refPreventsASiblingIdFromChangingTheBaseUriProvider
      */
+    #[DataProvider('refPreventsASiblingIdFromChangingTheBaseUriProvider')]
     public function testRefPreventsASiblingIdFromChangingTheBaseUriProvider($data, bool $expectedResult): void
     {
         $schema = json_decode(<<<'JSON'
diff --git a/tests/Entity/JsonPointerTest.php b/tests/Entity/JsonPointerTest.php
index f6be662..2ac0168 100644
--- a/tests/Entity/JsonPointerTest.php
+++ b/tests/Entity/JsonPointerTest.php
@@ -6,13 +6,12 @@ namespace JsonSchema\Tests\Entity;
 
 use JsonSchema\Entity\JsonPointer;
 use JsonSchema\Exception\InvalidArgumentException;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class JsonPointerTest extends TestCase
 {
-    /**
-     * @dataProvider jsonPointerDataProvider
-     */
+    #[DataProvider('jsonPointerDataProvider')]
     public function testJsonPointer(
         string $testValue,
         string $expectedFileName,
diff --git a/tests/JsonSchemaTestSuiteTest.php b/tests/JsonSchemaTestSuiteTest.php
index 0c4931b..30cfb84 100644
--- a/tests/JsonSchemaTestSuiteTest.php
+++ b/tests/JsonSchemaTestSuiteTest.php
@@ -9,6 +9,7 @@ use JsonSchema\Constraints\Factory;
 use JsonSchema\SchemaStorage;
 use JsonSchema\SchemaStorageInterface;
 use JsonSchema\Validator;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 use RecursiveDirectoryIterator;
 use RecursiveIteratorIterator;
@@ -20,6 +21,7 @@ class JsonSchemaTestSuiteTest extends TestCase
      *
      * @param mixed $data
      */
+    #[DataProvider('casesDataProvider')]
     public function testTestCaseValidatesCorrectly(
         string $testCaseDescription,
         string $testDescription,
diff --git a/tests/RefTest.php b/tests/RefTest.php
index 574fe9c..5ea6b66 100644
--- a/tests/RefTest.php
+++ b/tests/RefTest.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
 namespace JsonSchema\Tests;
 
 use JsonSchema\Validator;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class RefTest extends TestCase
@@ -56,7 +57,7 @@ class RefTest extends TestCase
         ];
     }
 
-    /** @dataProvider dataRefIgnoresSiblings */
+    #[DataProvider('dataRefIgnoresSiblings')]
     public function testRefIgnoresSiblings($schema, $document, $isValid, $exception = null): void
     {
         $document = json_decode($document);
diff --git a/tests/Rfc3339Test.php b/tests/Rfc3339Test.php
index 9c2f23f..9f314b4 100644
--- a/tests/Rfc3339Test.php
+++ b/tests/Rfc3339Test.php
@@ -5,13 +5,12 @@ declare(strict_types=1);
 namespace JsonSchema\Tests;
 
 use JsonSchema\Rfc3339;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class Rfc3339Test extends TestCase
 {
-    /**
-     * @dataProvider provideValidFormats
-     */
+    #[DataProvider('provideValidFormats')]
     public function testCreateFromValidString(string $string, \DateTime $expected): void
     {
         $actual = Rfc3339::createFromString($string);
@@ -20,9 +19,7 @@ class Rfc3339Test extends TestCase
         $this->assertEquals($expected->format('U.u'), $actual->format('U.u'));
     }
 
-    /**
-     * @dataProvider provideInvalidFormats
-     */
+    #[DataProvider('provideInvalidFormats')]
     public function testCreateFromInvalidString(string $string): void
     {
         $this->assertNull(Rfc3339::createFromString($string), sprintf('String "%s" should not be converted to DateTime', $string));
diff --git a/tests/Tool/DeepComparerTest.php b/tests/Tool/DeepComparerTest.php
index cb7b02a..197e42e 100644
--- a/tests/Tool/DeepComparerTest.php
+++ b/tests/Tool/DeepComparerTest.php
@@ -5,21 +5,18 @@ declare(strict_types=1);
 namespace JsonSchema\Tests\Tool;
 
 use JsonSchema\Tool\DeepComparer;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class DeepComparerTest extends TestCase
 {
-    /**
-     * @dataProvider equalDataProvider
-     */
+    #[DataProvider('equalDataProvider')]
     public function testComparesDeepEqualForEqualLeftAndRight($left, $right): void
     {
         self::assertTrue(DeepComparer::isEqual($left, $right));
     }
 
-    /**
-     * @dataProvider notEqualDataProvider
-     */
+    #[DataProvider('notEqualDataProvider')]
     public function testComparesDeepEqualForNotEqualLeftAndRight($left, $right): void
     {
         self::assertFalse(DeepComparer::isEqual($left, $right));
diff --git a/tests/Tool/Validator/RelativeReferenceValidatorTest.php b/tests/Tool/Validator/RelativeReferenceValidatorTest.php
index 2a9b6d6..04f1bd2 100644
--- a/tests/Tool/Validator/RelativeReferenceValidatorTest.php
+++ b/tests/Tool/Validator/RelativeReferenceValidatorTest.php
@@ -5,17 +5,18 @@ declare(strict_types=1);
 namespace Tool\Validator;
 
 use JsonSchema\Tool\Validator\RelativeReferenceValidator;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class RelativeReferenceValidatorTest extends TestCase
 {
-    /** @dataProvider validRelativeReferenceDataProvider */
+    #[DataProvider('validRelativeReferenceDataProvider')]
     public function testValidRelativeReferencesAreValidatedAsSuch(string $ref): void
     {
         self::assertTrue(RelativeReferenceValidator::isValid($ref));
     }
 
-    /** @dataProvider invalidRelativeReferenceDataProvider */
+    #[DataProvider('invalidRelativeReferenceDataProvider')]
     public function testInvalidRelativeReferencesAreValidatedAsSuch(string $ref): void
     {
         self::assertFalse(RelativeReferenceValidator::isValid($ref));
diff --git a/tests/Tool/Validator/UriValidatorTest.php b/tests/Tool/Validator/UriValidatorTest.php
index 80a45c8..83cc0d9 100644
--- a/tests/Tool/Validator/UriValidatorTest.php
+++ b/tests/Tool/Validator/UriValidatorTest.php
@@ -5,17 +5,18 @@ declare(strict_types=1);
 namespace Tool\Validator;
 
 use JsonSchema\Tool\Validator\UriValidator;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class UriValidatorTest extends TestCase
 {
-    /** @dataProvider validUriDataProvider */
+    #[DataProvider('validUriDataProvider')]
     public function testValidUrisAreValidatedAsSuch(string $uri): void
     {
         self::assertTrue(UriValidator::isValid($uri));
     }
 
-    /** @dataProvider invalidUriDataProvider */
+    #[DataProvider('invalidUriDataProvider')]
     public function testInvalidUrisAreValidatedAsSuch(string $uri): void
     {
         self::assertFalse(UriValidator::isValid($uri));
diff --git a/tests/Uri/UriRetrieverTest.php b/tests/Uri/UriRetrieverTest.php
index 013fb05..11c09c0 100644
--- a/tests/Uri/UriRetrieverTest.php
+++ b/tests/Uri/UriRetrieverTest.php
@@ -10,6 +10,7 @@ use JsonSchema\Exception\ResourceNotFoundException;
 use JsonSchema\Exception\UriResolverException;
 use JsonSchema\Uri\UriRetriever;
 use JsonSchema\Validator;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class UriRetrieverTest extends TestCase
@@ -39,9 +40,7 @@ class UriRetrieverTest extends TestCase
         return $retriever;
     }
 
-    /**
-     * @dataProvider jsonProvider
-     */
+    #[DataProvider('jsonProvider')]
     public function testChildExtendsParentValidTest($childSchema, $parentSchema): void
     {
         $this->mockRetriever($parentSchema);
@@ -54,9 +53,7 @@ class UriRetrieverTest extends TestCase
         $this->assertTrue($this->validator->isValid());
     }
 
-    /**
-     * @dataProvider jsonProvider
-     */
+    #[DataProvider('jsonProvider')]
     public function testChildExtendsParentInvalidChildTest($childSchema, $parentSchema): void
     {
         $this->mockRetriever($parentSchema);
@@ -69,9 +66,7 @@ class UriRetrieverTest extends TestCase
         $this->assertFalse($this->validator->isValid());
     }
 
-    /**
-     * @dataProvider jsonProvider
-     */
+    #[DataProvider('jsonProvider')]
     public function testChildExtendsParentInvalidParentTest($childSchema, $parentSchema): void
     {
         $this->mockRetriever($parentSchema);
@@ -84,9 +79,7 @@ class UriRetrieverTest extends TestCase
         $this->assertFalse($this->validator->isValid());
     }
 
-    /**
-     * @dataProvider jsonProvider
-     */
+    #[DataProvider('jsonProvider')]
     public function testResolveRelativeUri($childSchema, $parentSchema): void
     {
         self::setParentSchemaExtendsValue($parentSchema, 'grandparent');
@@ -422,9 +415,7 @@ EOF;
         ];
     }
 
-    /**
-     * @dataProvider combinedURITests
-     */
+    #[DataProvider('combinedURITests')]
     public function testResolveCombinedURI($uri, $baseURI, $combinedURI): void
     {
         $retriever = new UriRetriever();
