Skip to content

Commit 893a10a

Browse files
committed
test: migrate to phpunit 11
convert test annotations to PHP attributes The XML schema is the same for PHPunit 10 and 11, so that does not need to be migrated.
1 parent ab6441e commit 893a10a

5 files changed

Lines changed: 24 additions & 31 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"phpstan/phpstan-phpunit": "^2.0",
1919
"phpstan/phpstan-strict-rules": "^2.0",
2020
"phpstan/extension-installer": "^1.4",
21-
"phpunit/phpunit" : "^10.5",
21+
"phpunit/phpunit" : "^11.5",
2222
"rector/rector": "^2.4"
2323
},
2424
"suggest" : {

tests/HTTP/FunctionsTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44

55
namespace Sabre\HTTP;
66

7+
use PHPUnit\Framework\Attributes\DataProvider;
8+
79
class FunctionsTest extends \PHPUnit\Framework\TestCase
810
{
911
/**
10-
* @dataProvider getHeaderValuesDataOnValues2
11-
*
1212
* @param array<int, string> $result
1313
* @param array<int, string> $values1
1414
* @param array<int, string> $values2
1515
*/
16+
#[DataProvider('getHeaderValuesDataOnValues2')]
1617
public function testGetHeaderValuesOnValues2(array $result, array $values1, array $values2): void
1718
{
1819
self::assertEquals($result, getHeaderValues($values1, $values2));
@@ -38,11 +39,10 @@ public static function getHeaderValuesDataOnValues2(): array
3839
}
3940

4041
/**
41-
* @dataProvider getHeaderValuesData
42-
*
4342
* @param string $input
4443
* @param array<int, mixed> $output
4544
*/
45+
#[DataProvider('getHeaderValuesData')]
4646
public function testGetHeaderValues($input, array $output): void
4747
{
4848
self::assertEquals(
@@ -81,11 +81,10 @@ public static function getHeaderValuesData(): array
8181
}
8282

8383
/**
84-
* @dataProvider preferData
85-
*
8684
* @param string $input
8785
* @param array<int, mixed> $output
8886
*/
87+
#[DataProvider('preferData')]
8988
public function testPrefer($input, array $output): void
9089
{
9190
self::assertEquals(

tests/HTTP/NegotiateTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
namespace Sabre\HTTP;
66

7+
use PHPUnit\Framework\Attributes\DataProvider;
8+
79
class NegotiateTest extends \PHPUnit\Framework\TestCase
810
{
911
/**
10-
* @dataProvider negotiateData
11-
*
1212
* @param array<mixed, mixed> $available
1313
*/
14+
#[DataProvider('negotiateData')]
1415
public function testNegotiate(?string $acceptHeader, array $available, ?string $expected): void
1516
{
1617
self::assertEquals(

tests/HTTP/SapiTest.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace Sabre\HTTP;
66

7+
use PHPUnit\Framework\Attributes\DataProvider;
8+
use PHPUnit\Framework\Attributes\Depends;
9+
710
class SapiTest extends \PHPUnit\Framework\TestCase
811
{
912
public function testConstructFromServerArray(): void
@@ -144,9 +147,8 @@ public function testSend(): void
144147

145148
/**
146149
* @runInSeparateProcess
147-
*
148-
* @depends testSend
149150
*/
151+
#[Depends('testSend')]
150152
public function testSendLimitedByContentLengthString(): void
151153
{
152154
$response = new Response(200);
@@ -180,9 +182,8 @@ public function testRecognizeHttp2(): void
180182

181183
/**
182184
* @runInSeparateProcess
183-
*
184-
* @depends testSend
185185
*/
186+
#[Depends('testSend')]
186187
public function testSendLimitedByContentLengthStream(): void
187188
{
188189
$response = new Response(200, ['Content-Length' => 19]);
@@ -205,17 +206,15 @@ public function testSendLimitedByContentLengthStream(): void
205206

206207
/**
207208
* @runInSeparateProcess
208-
*
209-
* @depends testSend
210-
*
211-
* @dataProvider sendContentRangeStreamData
212209
*/
210+
#[Depends('testSend')]
211+
#[DataProvider('sendContentRangeStreamData')]
213212
public function testSendContentRangeStream(
214213
string $ignoreAtStart,
215214
string $sendText,
216215
int $multiplier,
217216
string $ignoreAtEnd,
218-
?int $contentLength): void
217+
?int $contentLength = null): void
219218
{
220219
$partial = str_repeat($sendText, $multiplier);
221220
$ignoreAtStartLength = strlen($ignoreAtStart);
@@ -281,9 +280,8 @@ public static function sendContentRangeStreamData(): array
281280

282281
/**
283282
* @runInSeparateProcess
284-
*
285-
* @depends testSend
286283
*/
284+
#[Depends('testSend')]
287285
public function testSendWorksWithCallbackAsBody(): void
288286
{
289287
$response = new Response(200, [], function (): void {

tests/HTTP/URLUtilTest.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Sabre\HTTP;
66

7+
use PHPUnit\Framework\Attributes\Depends;
8+
79
class URLUtilTest extends \PHPUnit\Framework\TestCase
810
{
911
public function testEncodePath(): void
@@ -61,19 +63,15 @@ public function testDecode(): void
6163
self::assertEquals('Hello Test+Test2.txt', $newStr);
6264
}
6365

64-
/**
65-
* @depends testDecode
66-
*/
66+
#[Depends('testDecode')]
6767
public function testDecodeUmlaut(): void
6868
{
6969
$str = 'Hello%C3%BC.txt';
7070
$newStr = decodePath($str);
7171
self::assertEquals("Hello\xC3\xBC.txt", $newStr);
7272
}
7373

74-
/**
75-
* @depends testDecode
76-
*/
74+
#[Depends('testDecode')]
7775
public function testDecodeSlavicWords(): void
7876
{
7977
$words = [
@@ -90,9 +88,7 @@ public function testDecodeSlavicWords(): void
9088
}
9189
}
9290

93-
/**
94-
* @depends testDecodeUmlaut
95-
*/
91+
#[Depends('testDecodeUmlaut')]
9692
public function testDecodeUmlautLatin1(): void
9793
{
9894
$str = 'Hello%FC.txt';
@@ -102,9 +98,8 @@ public function testDecodeUmlautLatin1(): void
10298

10399
/**
104100
* This testcase was sent by a bug reporter.
105-
*
106-
* @depends testDecode
107101
*/
102+
#[Depends('testDecode')]
108103
public function testDecodeAccentsWindows7(): void
109104
{
110105
$str = '/webdav/%C3%A0fo%C3%B3';

0 commit comments

Comments
 (0)