4
4
5
5
namespace Pdp ;
6
6
7
+ use PHPUnit \Framework \Attributes \DataProvider ;
7
8
use PHPUnit \Framework \TestCase ;
8
9
use stdClass ;
9
10
use TypeError ;
10
11
11
- /**
12
- * @coversDefaultClass \Pdp\Domain
13
- */
14
12
final class DomainTest extends TestCase
15
13
{
16
- /**
17
- * @covers \Pdp\SyntaxError
18
- * @dataProvider invalidDomainProvider
19
- */
14
+ #[DataProvider('invalidDomainProvider ' )]
20
15
public function testToAsciiThrowsException (string $ domain ): void
21
16
{
22
17
$ this ->expectException (SyntaxError::class);
@@ -27,7 +22,7 @@ public function testToAsciiThrowsException(string $domain): void
27
22
/**
28
23
* @return iterable<string,array{0:string}>
29
24
*/
30
- public function invalidDomainProvider (): iterable
25
+ public static function invalidDomainProvider (): iterable
31
26
{
32
27
return [
33
28
'invalid IDN domain ' => ['a⒈com ' ],
@@ -56,10 +51,9 @@ public function testDomainInternalPhpMethod(): void
56
51
}
57
52
58
53
/**
59
- * @dataProvider countableProvider
60
- *
61
- * @param string[] $labels
54
+ * @param array<string> $labels
62
55
*/
56
+ #[DataProvider('countableProvider ' )]
63
57
public function testCountable (?string $ domain , int $ nbLabels , array $ labels ): void
64
58
{
65
59
$ domain = Domain::fromIDNA2008 ($ domain );
@@ -70,7 +64,7 @@ public function testCountable(?string $domain, int $nbLabels, array $labels): vo
70
64
/**
71
65
* @return iterable<string,array{0:string|null, 1:int, 2:array<string>}>
72
66
*/
73
- public function countableProvider (): iterable
67
+ public static function countableProvider (): iterable
74
68
{
75
69
return [
76
70
'null ' => [null , 0 , []],
@@ -112,9 +106,7 @@ public function testLabels(): void
112
106
self ::assertSame ([], Domain::fromIDNA2008 (null )->labels ());
113
107
}
114
108
115
- /**
116
- * @dataProvider toUnicodeProvider
117
- */
109
+ #[DataProvider('toUnicodeProvider ' )]
118
110
public function testToIDN (
119
111
?string $ domain ,
120
112
?string $ expectedDomain ,
@@ -131,7 +123,7 @@ public function testToIDN(
131
123
/**
132
124
* @return iterable<string,array{domain:string|null, expectedDomain:string|null, expectedIDNDomain:string|null}>
133
125
*/
134
- public function toUnicodeProvider (): iterable
126
+ public static function toUnicodeProvider (): iterable
135
127
{
136
128
return [
137
129
'simple domain ' => [
@@ -172,9 +164,7 @@ public function toUnicodeProvider(): iterable
172
164
];
173
165
}
174
166
175
- /**
176
- * @dataProvider toAsciiProvider
177
- */
167
+ #[DataProvider('toAsciiProvider ' )]
178
168
public function testToAscii (
179
169
?string $ domain ,
180
170
?string $ expectedDomain ,
@@ -191,7 +181,7 @@ public function testToAscii(
191
181
/**
192
182
* @return iterable<string,array{domain:string|null, expectedDomain:string|null, expectedIDNDomain:string|null}>
193
183
*/
194
- public function toAsciiProvider (): iterable
184
+ public static function toAsciiProvider (): iterable
195
185
{
196
186
return [
197
187
'simple domain ' => [
@@ -222,9 +212,7 @@ public function toAsciiProvider(): iterable
222
212
];
223
213
}
224
214
225
- /**
226
- * @dataProvider withLabelWorksProvider
227
- */
215
+ #[DataProvider('withLabelWorksProvider ' )]
228
216
public function testWithLabelWorks (DomainName $ domain , int $ key , string $ label , ?string $ expected ): void
229
217
{
230
218
$ result = $ domain ->withLabel ($ key , $ label );
@@ -234,7 +222,7 @@ public function testWithLabelWorks(DomainName $domain, int $key, string $label,
234
222
/**
235
223
* @return iterable<string,array{domain:DomainName, key:int, label:string, expected:string}>
236
224
*/
237
- public function withLabelWorksProvider (): iterable
225
+ public static function withLabelWorksProvider (): iterable
238
226
{
239
227
$ base_domain = Domain::fromIDNA2008 ('www.example.com ' );
240
228
@@ -321,9 +309,7 @@ public function testWithLabelFailsWithInvalidLabel2(): void
321
309
Domain::fromIDNA2008 ('example.com ' )->withLabel (-1 , '' );
322
310
}
323
311
324
- /**
325
- * @dataProvider validAppend
326
- */
312
+ #[DataProvider('validAppend ' )]
327
313
public function testAppend (string $ raw , string $ append , string $ expected ): void
328
314
{
329
315
self ::assertSame ($ expected , Domain::fromIDNA2008 ($ raw )->append ($ append )->toString ());
@@ -332,7 +318,7 @@ public function testAppend(string $raw, string $append, string $expected): void
332
318
/**
333
319
* @return iterable<array-key, array{0:string, 1:string, 2:string}>
334
320
*/
335
- public function validAppend (): iterable
321
+ public static function validAppend (): iterable
336
322
{
337
323
return [
338
324
['secure.example.com ' , '8.8.8.8 ' , 'secure.example.com.8.8.8.8 ' ],
@@ -342,9 +328,7 @@ public function validAppend(): iterable
342
328
];
343
329
}
344
330
345
- /**
346
- * @dataProvider validPrepend
347
- */
331
+ #[DataProvider('validPrepend ' )]
348
332
public function testPrepend (string $ raw , string $ prepend , string $ expected ): void
349
333
{
350
334
self ::assertSame ($ expected , Domain::fromIDNA2008 ($ raw )->prepend ($ prepend )->toString ());
@@ -353,7 +337,7 @@ public function testPrepend(string $raw, string $prepend, string $expected): voi
353
337
/**
354
338
* @return iterable<array-key, array{0:string, 1:string, 2:string}>
355
339
*/
356
- public function validPrepend (): iterable
340
+ public static function validPrepend (): iterable
357
341
{
358
342
return [
359
343
['secure.example.com ' , 'master ' , 'master.secure.example.com ' ],
@@ -362,9 +346,7 @@ public function validPrepend(): iterable
362
346
];
363
347
}
364
348
365
- /**
366
- * @dataProvider withoutLabelWorksProvider
367
- */
349
+ #[DataProvider('withoutLabelWorksProvider ' )]
368
350
public function testwithoutLabelWorks (DomainName $ domain , int $ key , ?string $ expected ): void
369
351
{
370
352
$ result = $ domain ->withoutLabel ($ key );
@@ -374,7 +356,7 @@ public function testwithoutLabelWorks(DomainName $domain, int $key, ?string $exp
374
356
/**
375
357
* @return iterable<string,array{domain:DomainName, key:int, expected:string}>
376
358
*/
377
- public function withoutLabelWorksProvider (): iterable
359
+ public static function withoutLabelWorksProvider (): iterable
378
360
{
379
361
$ base_domain = Domain::fromIDNA2008 ('www.example.com ' );
380
362
@@ -413,9 +395,7 @@ public function testwithoutLabelWorksWithMultipleKeys(): void
413
395
self ::assertNull (Domain::fromIDNA2008 ('www.example.com ' )->withoutLabel (0 , 1 , 2 )->value ());
414
396
}
415
397
416
- /**
417
- * @dataProvider resolveCustomIDNAOptionsProvider
418
- */
398
+ #[DataProvider('resolveCustomIDNAOptionsProvider ' )]
419
399
public function testResolveWorksWithCustomIDNAOptions (
420
400
string $ domainName ,
421
401
string $ withLabel ,
@@ -434,7 +414,7 @@ public function testResolveWorksWithCustomIDNAOptions(
434
414
/**
435
415
* @return iterable<string,array<string>>
436
416
*/
437
- public function resolveCustomIDNAOptionsProvider (): iterable
417
+ public static function resolveCustomIDNAOptionsProvider (): iterable
438
418
{
439
419
return [
440
420
'without deviation characters ' => [
0 commit comments