Skip to content

Commit 87b2ca9

Browse files
committed
Using PHPUnit 10
1 parent fe22f70 commit 87b2ca9

15 files changed

+79
-202
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ docs
44
build
55
pdp
66
.idea
7+
.phpunit.cache
78
.php_cs.cache
89
.php-cs-fixer.cache
9-
.phpunit.result.cache
1010
composer.lock

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@
4949
"friendsofphp/php-cs-fixer": "^v3.13.2",
5050
"guzzlehttp/guzzle": "^7.5",
5151
"guzzlehttp/psr7": "^1.6 || ^2.4.3",
52-
"phpstan/phpstan": "^1.9.6",
53-
"phpstan/phpstan-phpunit": "^1.3.3",
54-
"phpstan/phpstan-strict-rules": "^1.4.4",
55-
"phpunit/phpunit": "^9.5.27",
52+
"phpstan/phpstan": "^1.9.17",
53+
"phpstan/phpstan-phpunit": "^1.3.4",
54+
"phpstan/phpstan-strict-rules": "^1.4.5",
55+
"phpunit/phpunit": "^10.0.7",
5656
"psr/http-factory": "^1.0.1",
5757
"psr/simple-cache": "^1.0.1",
5858
"symfony/cache": "^v5.0.0 || ^v6.0.0"

phpunit.xml.dist

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
55
bootstrap="vendor/autoload.php"
66
backupGlobals="false"
7-
backupStaticAttributes="false"
87
colors="true"
9-
verbose="true"
10-
convertErrorsToExceptions="true"
11-
convertNoticesToExceptions="true"
12-
convertWarningsToExceptions="true"
138
processIsolation="false"
14-
stopOnFailure="false">
9+
stopOnFailure="false"
10+
cacheDirectory=".phpunit.cache"
11+
backupStaticProperties="false"
12+
>
1513
<coverage>
1614
<include>
1715
<directory suffix=".php">src</directory>

src/DomainTest.php

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,14 @@
44

55
namespace Pdp;
66

7+
use PHPUnit\Framework\Attributes\DataProvider;
78
use PHPUnit\Framework\TestCase;
89
use stdClass;
910
use TypeError;
1011

11-
/**
12-
* @coversDefaultClass \Pdp\Domain
13-
*/
1412
final class DomainTest extends TestCase
1513
{
16-
/**
17-
* @covers \Pdp\SyntaxError
18-
* @dataProvider invalidDomainProvider
19-
*/
14+
#[DataProvider('invalidDomainProvider')]
2015
public function testToAsciiThrowsException(string $domain): void
2116
{
2217
$this->expectException(SyntaxError::class);
@@ -27,7 +22,7 @@ public function testToAsciiThrowsException(string $domain): void
2722
/**
2823
* @return iterable<string,array{0:string}>
2924
*/
30-
public function invalidDomainProvider(): iterable
25+
public static function invalidDomainProvider(): iterable
3126
{
3227
return [
3328
'invalid IDN domain' => ['a⒈com'],
@@ -56,10 +51,9 @@ public function testDomainInternalPhpMethod(): void
5651
}
5752

5853
/**
59-
* @dataProvider countableProvider
60-
*
61-
* @param string[] $labels
54+
* @param array<string> $labels
6255
*/
56+
#[DataProvider('countableProvider')]
6357
public function testCountable(?string $domain, int $nbLabels, array $labels): void
6458
{
6559
$domain = Domain::fromIDNA2008($domain);
@@ -70,7 +64,7 @@ public function testCountable(?string $domain, int $nbLabels, array $labels): vo
7064
/**
7165
* @return iterable<string,array{0:string|null, 1:int, 2:array<string>}>
7266
*/
73-
public function countableProvider(): iterable
67+
public static function countableProvider(): iterable
7468
{
7569
return [
7670
'null' => [null, 0, []],
@@ -112,9 +106,7 @@ public function testLabels(): void
112106
self::assertSame([], Domain::fromIDNA2008(null)->labels());
113107
}
114108

115-
/**
116-
* @dataProvider toUnicodeProvider
117-
*/
109+
#[DataProvider('toUnicodeProvider')]
118110
public function testToIDN(
119111
?string $domain,
120112
?string $expectedDomain,
@@ -131,7 +123,7 @@ public function testToIDN(
131123
/**
132124
* @return iterable<string,array{domain:string|null, expectedDomain:string|null, expectedIDNDomain:string|null}>
133125
*/
134-
public function toUnicodeProvider(): iterable
126+
public static function toUnicodeProvider(): iterable
135127
{
136128
return [
137129
'simple domain' => [
@@ -172,9 +164,7 @@ public function toUnicodeProvider(): iterable
172164
];
173165
}
174166

175-
/**
176-
* @dataProvider toAsciiProvider
177-
*/
167+
#[DataProvider('toAsciiProvider')]
178168
public function testToAscii(
179169
?string $domain,
180170
?string $expectedDomain,
@@ -191,7 +181,7 @@ public function testToAscii(
191181
/**
192182
* @return iterable<string,array{domain:string|null, expectedDomain:string|null, expectedIDNDomain:string|null}>
193183
*/
194-
public function toAsciiProvider(): iterable
184+
public static function toAsciiProvider(): iterable
195185
{
196186
return [
197187
'simple domain' => [
@@ -222,9 +212,7 @@ public function toAsciiProvider(): iterable
222212
];
223213
}
224214

225-
/**
226-
* @dataProvider withLabelWorksProvider
227-
*/
215+
#[DataProvider('withLabelWorksProvider')]
228216
public function testWithLabelWorks(DomainName $domain, int $key, string $label, ?string $expected): void
229217
{
230218
$result = $domain->withLabel($key, $label);
@@ -234,7 +222,7 @@ public function testWithLabelWorks(DomainName $domain, int $key, string $label,
234222
/**
235223
* @return iterable<string,array{domain:DomainName, key:int, label:string, expected:string}>
236224
*/
237-
public function withLabelWorksProvider(): iterable
225+
public static function withLabelWorksProvider(): iterable
238226
{
239227
$base_domain = Domain::fromIDNA2008('www.example.com');
240228

@@ -321,9 +309,7 @@ public function testWithLabelFailsWithInvalidLabel2(): void
321309
Domain::fromIDNA2008('example.com')->withLabel(-1, '');
322310
}
323311

324-
/**
325-
* @dataProvider validAppend
326-
*/
312+
#[DataProvider('validAppend')]
327313
public function testAppend(string $raw, string $append, string $expected): void
328314
{
329315
self::assertSame($expected, Domain::fromIDNA2008($raw)->append($append)->toString());
@@ -332,7 +318,7 @@ public function testAppend(string $raw, string $append, string $expected): void
332318
/**
333319
* @return iterable<array-key, array{0:string, 1:string, 2:string}>
334320
*/
335-
public function validAppend(): iterable
321+
public static function validAppend(): iterable
336322
{
337323
return [
338324
['secure.example.com', '8.8.8.8', 'secure.example.com.8.8.8.8'],
@@ -342,9 +328,7 @@ public function validAppend(): iterable
342328
];
343329
}
344330

345-
/**
346-
* @dataProvider validPrepend
347-
*/
331+
#[DataProvider('validPrepend')]
348332
public function testPrepend(string $raw, string $prepend, string $expected): void
349333
{
350334
self::assertSame($expected, Domain::fromIDNA2008($raw)->prepend($prepend)->toString());
@@ -353,7 +337,7 @@ public function testPrepend(string $raw, string $prepend, string $expected): voi
353337
/**
354338
* @return iterable<array-key, array{0:string, 1:string, 2:string}>
355339
*/
356-
public function validPrepend(): iterable
340+
public static function validPrepend(): iterable
357341
{
358342
return [
359343
['secure.example.com', 'master', 'master.secure.example.com'],
@@ -362,9 +346,7 @@ public function validPrepend(): iterable
362346
];
363347
}
364348

365-
/**
366-
* @dataProvider withoutLabelWorksProvider
367-
*/
349+
#[DataProvider('withoutLabelWorksProvider')]
368350
public function testwithoutLabelWorks(DomainName $domain, int $key, ?string $expected): void
369351
{
370352
$result = $domain->withoutLabel($key);
@@ -374,7 +356,7 @@ public function testwithoutLabelWorks(DomainName $domain, int $key, ?string $exp
374356
/**
375357
* @return iterable<string,array{domain:DomainName, key:int, expected:string}>
376358
*/
377-
public function withoutLabelWorksProvider(): iterable
359+
public static function withoutLabelWorksProvider(): iterable
378360
{
379361
$base_domain = Domain::fromIDNA2008('www.example.com');
380362

@@ -413,9 +395,7 @@ public function testwithoutLabelWorksWithMultipleKeys(): void
413395
self::assertNull(Domain::fromIDNA2008('www.example.com')->withoutLabel(0, 1, 2)->value());
414396
}
415397

416-
/**
417-
* @dataProvider resolveCustomIDNAOptionsProvider
418-
*/
398+
#[DataProvider('resolveCustomIDNAOptionsProvider')]
419399
public function testResolveWorksWithCustomIDNAOptions(
420400
string $domainName,
421401
string $withLabel,
@@ -434,7 +414,7 @@ public function testResolveWorksWithCustomIDNAOptions(
434414
/**
435415
* @return iterable<string,array<string>>
436416
*/
437-
public function resolveCustomIDNAOptionsProvider(): iterable
417+
public static function resolveCustomIDNAOptionsProvider(): iterable
438418
{
439419
return [
440420
'without deviation characters' => [

0 commit comments

Comments
 (0)