File: 0003-Modernize-PHPUnit-syntax.patch

package info (click to toggle)
php-json-schema 6.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,216 kB
  • sloc: php: 9,403; makefile: 153; python: 28; sh: 13
file content (520 lines) | stat: -rw-r--r-- 18,854 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
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                  | 17 +++++------------
 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/Entity/JsonPointerTest.php                    |  5 ++---
 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 ++++++---------------
 14 files changed, 47 insertions(+), 85 deletions(-)

diff --git a/tests/Constraints/BaseTestCase.php b/tests/Constraints/BaseTestCase.php
index ba55b46..009c2d7 100644
--- a/tests/Constraints/BaseTestCase.php
+++ b/tests/Constraints/BaseTestCase.php
@@ -14,6 +14,7 @@ use JsonSchema\Constraints\Factory;
 use JsonSchema\SchemaStorage;
 use JsonSchema\Uri\UriResolver;
 use JsonSchema\Validator;
+use PHPUnit\Framework\Attributes\DataProvider;
 
 /**
  * @package JsonSchema\Tests\Constraints
@@ -23,9 +24,7 @@ abstract class BaseTestCase extends VeryBaseTestCase
     protected $schemaSpec = 'http://json-schema.org/draft-04/schema#';
     protected $validateSchema = false;
 
-    /**
-     * @dataProvider getInvalidTests
-     */
+    #[DataProvider('getInvalidTests')]
     public function testInvalidCases($input, $schema, $checkMode = Constraint::CHECK_MODE_NORMAL, $errors = []): void
     {
         $checkMode = $checkMode === null ? Constraint::CHECK_MODE_NORMAL : $checkMode;
@@ -52,9 +51,7 @@ abstract class BaseTestCase extends VeryBaseTestCase
         $this->assertFalse($validator->isValid(), print_r($validator->getErrors(), true));
     }
 
-    /**
-     * @dataProvider getInvalidForAssocTests
-     */
+    #[DataProvider('getInvalidForAssocTests')]
     public function testInvalidCasesUsingAssoc($input, $schema, $checkMode = Constraint::CHECK_MODE_TYPE_CAST, $errors = []): void
     {
         $checkMode = $checkMode === null ? Constraint::CHECK_MODE_TYPE_CAST : $checkMode;
@@ -84,9 +81,7 @@ abstract class BaseTestCase extends VeryBaseTestCase
         $this->assertFalse($validator->isValid(), print_r($validator->getErrors(), true));
     }
 
-    /**
-     * @dataProvider getValidTests
-     */
+    #[DataProvider('getValidTests')]
     public function testValidCases($input, $schema, $checkMode = Constraint::CHECK_MODE_NORMAL): void
     {
         if ($this->validateSchema) {
@@ -106,9 +101,7 @@ abstract class BaseTestCase extends VeryBaseTestCase
         $this->assertTrue($validator->isValid(), print_r($validator->getErrors(), true));
     }
 
-    /**
-     * @dataProvider getValidForAssocTests
-     */
+    #[DataProvider('getValidForAssocTests')]
     public function testValidCasesUsingAssoc($input, $schema, $checkMode = Constraint::CHECK_MODE_TYPE_CAST): void
     {
         if ($this->validateSchema) {
diff --git a/tests/Constraints/CoerciveTest.php b/tests/Constraints/CoerciveTest.php
index 3c028ba..eef2fc1 100644
--- a/tests/Constraints/CoerciveTest.php
+++ b/tests/Constraints/CoerciveTest.php
@@ -13,6 +13,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
 {
@@ -189,7 +190,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);
@@ -231,7 +232,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 2849835..702de51 100644
--- a/tests/Constraints/DefaultPropertiesTest.php
+++ b/tests/Constraints/DefaultPropertiesTest.php
@@ -13,6 +13,7 @@ use JsonSchema\Constraints\Constraint;
 use JsonSchema\Constraints\Factory;
 use JsonSchema\SchemaStorage;
 use JsonSchema\Validator;
+use PHPUnit\Framework\Attributes\DataProvider;
 
 class DefaultPropertiesTest extends VeryBaseTestCase
 {
@@ -167,9 +168,7 @@ class DefaultPropertiesTest extends VeryBaseTestCase
         ];
     }
 
-    /**
-     * @dataProvider getValidTests
-     */
+    #[DataProvider('getValidTests')]
     public function testValidCases($input, $schema, $expectOutput = null, $checkMode = 0): void
     {
         if (is_string($input)) {
@@ -194,9 +193,7 @@ class DefaultPropertiesTest extends VeryBaseTestCase
         }
     }
 
-    /**
-     * @dataProvider getValidTests
-     */
+    #[DataProvider('getValidTests')]
     public function testValidCasesUsingAssoc($input, $schema, $expectOutput = null, $checkMode = 0): void
     {
         $input = json_decode($input, true);
@@ -205,9 +202,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 9136f50..70917a4 100644
--- a/tests/Constraints/FactoryTest.php
+++ b/tests/Constraints/FactoryTest.php
@@ -17,6 +17,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
@@ -32,9 +33,7 @@ class MyStringConstraint extends Constraint
 
 class FactoryTest extends TestCase
 {
-    /**
-     * @dataProvider constraintNameProvider
-     */
+    #[DataProvider('constraintNameProvider')]
     public function testCreateInstanceForConstraintName(string $constraintName, string $expectedClass): void
     {
         $factory = new Factory();
@@ -59,9 +58,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 25eab1c..03a45dd 100644
--- a/tests/Constraints/FormatTest.php
+++ b/tests/Constraints/FormatTest.php
@@ -12,6 +12,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
 {
@@ -54,9 +55,7 @@ class FormatTest extends BaseTestCase
         $this->assertEmpty($validator->getErrors());
     }
 
-    /**
-     * @dataProvider getValidFormats
-     */
+    #[DataProvider('getValidFormats')]
     public function testValidFormat($string, $format): void
     {
         $validator = new FormatConstraint();
@@ -67,9 +66,7 @@ class FormatTest extends BaseTestCase
         $this->assertEmpty($validator->getErrors());
     }
 
-    /**
-     * @dataProvider getInvalidFormats
-     */
+    #[DataProvider('getInvalidFormats')]
     public function testInvalidFormat($string, $format): void
     {
         $validator = new FormatConstraint();
@@ -80,9 +77,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 65268f4..7b20061 100644
--- a/tests/Constraints/SchemaValidationTest.php
+++ b/tests/Constraints/SchemaValidationTest.php
@@ -11,6 +11,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
@@ -61,9 +62,7 @@ class SchemaValidationTest extends TestCase
         ];
     }
 
-    /**
-     * @dataProvider getInvalidTests
-     */
+    #[DataProvider('getInvalidTests')]
     public function testInvalidCases($schema): void
     {
         $input = json_decode('{"propertyOne":"valueOne"}');
@@ -82,9 +81,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 1b6edc4..8056e65 100644
--- a/tests/Constraints/TypeTest.php
+++ b/tests/Constraints/TypeTest.php
@@ -11,6 +11,7 @@ namespace JsonSchema\Tests\Constraints;
 
 use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
 use JsonSchema\Constraints\TypeConstraint;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 /**
@@ -41,9 +42,7 @@ class TypeTest extends TestCase
         ];
     }
 
-    /**
-     * @dataProvider provideIndefiniteArticlesForTypes
-     */
+    #[DataProvider('provideIndefiniteArticlesForTypes')]
     public function testIndefiniteArticleForTypeInTypeCheckErrorMessage($type, $wording, $value = null, $label = 'NULL'): void
     {
         $constraint = new TypeConstraint();
@@ -100,9 +99,7 @@ class TypeTest extends TestCase
         return $wordings;
     }
 
-    /**
-     * @dataProvider validNameWordingDataProvider
-     */
+    #[DataProvider('validNameWordingDataProvider')]
     public function testValidateTypeNameWording($nameWording): void
     {
         $t = new TypeConstraint();
diff --git a/tests/Entity/JsonPointerTest.php b/tests/Entity/JsonPointerTest.php
index cb27c68..3f7dff6 100644
--- a/tests/Entity/JsonPointerTest.php
+++ b/tests/Entity/JsonPointerTest.php
@@ -13,6 +13,7 @@ namespace JsonSchema\Tests\Entity;
 
 use JsonSchema\Entity\JsonPointer;
 use JsonSchema\Exception\InvalidArgumentException;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 /**
@@ -22,9 +23,7 @@ use PHPUnit\Framework\TestCase;
  */
 class JsonPointerTest extends TestCase
 {
-    /**
-     * @dataProvider jsonPointerDataProvider
-     */
+    #[DataProvider('jsonPointerDataProvider')]
     public function testJsonPointer(
         string $testValue,
         string $expectedFileName,
diff --git a/tests/RefTest.php b/tests/RefTest.php
index 3b66d58..7ebaf64 100644
--- a/tests/RefTest.php
+++ b/tests/RefTest.php
@@ -10,6 +10,7 @@
 namespace JsonSchema\Tests;
 
 use JsonSchema\Validator;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class RefTest extends TestCase
@@ -61,7 +62,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 e1addf8..1343dbf 100644
--- a/tests/Uri/UriRetrieverTest.php
+++ b/tests/Uri/UriRetrieverTest.php
@@ -15,6 +15,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;
 
 /**
@@ -47,9 +48,7 @@ class UriRetrieverTest extends TestCase
         return $retriever;
     }
 
-    /**
-     * @dataProvider jsonProvider
-     */
+    #[DataProvider('jsonProvider')]
     public function testChildExtendsParentValidTest($childSchema, $parentSchema): void
     {
         $this->mockRetriever($parentSchema);
@@ -62,9 +61,7 @@ class UriRetrieverTest extends TestCase
         $this->assertTrue($this->validator->isValid());
     }
 
-    /**
-     * @dataProvider jsonProvider
-     */
+    #[DataProvider('jsonProvider')]
     public function testChildExtendsParentInvalidChildTest($childSchema, $parentSchema): void
     {
         $this->mockRetriever($parentSchema);
@@ -77,9 +74,7 @@ class UriRetrieverTest extends TestCase
         $this->assertFalse($this->validator->isValid());
     }
 
-    /**
-     * @dataProvider jsonProvider
-     */
+    #[DataProvider('jsonProvider')]
     public function testChildExtendsParentInvalidParentTest($childSchema, $parentSchema): void
     {
         $this->mockRetriever($parentSchema);
@@ -92,9 +87,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();