Skip to content

Commit fbab1ff

Browse files
authored
Migrate the testsuite to PHPUnit 11 (#1977)
1 parent 3ce22ad commit fbab1ff

File tree

13 files changed

+82
-100
lines changed

13 files changed

+82
-100
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ jobs:
3131
- name: Download dependencies
3232
run: |
3333
composer config minimum-stability dev
34-
composer req symfony/phpunit-bridge --no-update
3534
composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable
3635
3736
- name: Run tests
38-
run: ./vendor/bin/simple-phpunit
37+
run: ./vendor/bin/phpunit

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ start-docker-s3:
1414
docker run -d -p 4569:4569 -p 4570:4569 --name async_aws_s3 asyncaws/testing-s3
1515

1616
test: initialize
17-
./vendor/bin/simple-phpunit
17+
./vendor/bin/phpunit
1818

1919
clean: stop-docker
2020
stop-docker:

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"symfony/http-client-contracts": "^1.1.8 || ^2.0 || ^3.0",
2323
"symfony/service-contracts": "^1.0 || ^2.0 || ^3.0"
2424
},
25+
"require-dev": {
26+
"phpunit/phpunit": "^11.5.42",
27+
"symfony/error-handler": "^7.3.2 || ^8.0",
28+
"symfony/phpunit-bridge": "^7.3.2 || ^8.0"
29+
},
2530
"conflict": {
2631
"async-aws/s3": "<1.1",
2732
"symfony/http-client": "5.2.0"

phpunit.xml.dist

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php" failOnRisky="true" failOnWarning="true">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
4+
backupGlobals="false"
5+
colors="true"
6+
bootstrap="vendor/autoload.php"
7+
failOnRisky="true"
8+
failOnWarning="true"
9+
failOnDeprecation="true"
10+
failOnNotice="true"
11+
>
12+
<source ignoreSuppressionOfDeprecations="true">
13+
<include>
14+
<directory>./src</directory>
15+
</include>
16+
<deprecationTrigger>
17+
<function>trigger_deprecation</function>
18+
</deprecationTrigger>
19+
</source>
320
<php>
421
<ini name="error_reporting" value="-1"/>
522
</php>
@@ -8,9 +25,7 @@
825
<directory>./tests/</directory>
926
</testsuite>
1027
</testsuites>
11-
<source>
12-
<include>
13-
<directory>./src</directory>
14-
</include>
15-
</source>
28+
<extensions>
29+
<bootstrap class="Symfony\Bridge\PhpUnit\SymfonyExtension"/>
30+
</extensions>
1631
</phpunit>

tests/HttpClient/AwsRetryStrategyTest.php

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

55
use AsyncAws\Core\HttpClient\AwsRetryStrategy;
66
use AsyncAws\Core\Test\TestCase;
7+
use PHPUnit\Framework\Attributes\DataProvider;
78
use Symfony\Component\HttpClient\MockHttpClient;
89
use Symfony\Component\HttpClient\Response\AsyncContext;
910
use Symfony\Component\HttpClient\Response\MockResponse;
1011
use Symfony\Component\HttpClient\Retry\GenericRetryStrategy;
1112

1213
class AwsRetryStrategyTest extends TestCase
1314
{
14-
/**
15-
* @dataProvider provideRetries
16-
*/
17-
public function testShoudRetry(?bool $expected, int $statusCode, ?string $response): void
15+
#[DataProvider('provideRetries')]
16+
public function testShouldRetry(?bool $expected, int $statusCode, ?string $response): void
1817
{
1918
if (!class_exists(GenericRetryStrategy::class)) {
2019
self::markTestSkipped('AwsRetryStrategy requires symfony/http-client 5.2');
@@ -25,7 +24,7 @@ public function testShoudRetry(?bool $expected, int $statusCode, ?string $respon
2524
self::assertSame($expected, $strategy->shouldRetry($context, $response, null));
2625
}
2726

28-
public function provideRetries(): iterable
27+
public static function provideRetries(): iterable
2928
{
3029
yield [false, 200, null];
3130
yield [true, 429, null];

tests/Unit/ConfigurationTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
namespace AsyncAws\Core\Tests\Unit;
66

77
use AsyncAws\Core\Configuration;
8+
use PHPUnit\Framework\Attributes\DataProvider;
89
use PHPUnit\Framework\TestCase;
910

1011
class ConfigurationTest extends TestCase
1112
{
12-
/**
13-
* @dataProvider provideConfiguration
14-
*/
13+
#[DataProvider('provideConfiguration')]
1514
public function testCreate($config, $env, $expected)
1615
{
1716
foreach ($env as $key => $value) {
@@ -61,7 +60,7 @@ public function testIsDefaultWhenPassingNull()
6160
self::assertNull($config->get('accessKeySecret'));
6261
}
6362

64-
public function provideConfiguration(): iterable
63+
public static function provideConfiguration(): iterable
6564
{
6665
yield 'simple config' => [['endpoint' => 'foo'], [], ['endpoint' => 'foo']];
6766
yield 'empty config' => [['endpoint' => ''], [], ['endpoint' => '']];

tests/Unit/Signer/SignerV4Test.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use AsyncAws\Core\RequestContext;
1010
use AsyncAws\Core\Signer\SignerV4;
1111
use AsyncAws\Core\Stream\StringStream;
12+
use PHPUnit\Framework\Attributes\DataProvider;
1213
use PHPUnit\Framework\TestCase;
1314

1415
class SignerV4Test extends TestCase
@@ -60,9 +61,7 @@ public function testPresign()
6061
self::assertEqualsCanonicalizing($expectedQuery, $request->getQuery());
6162
}
6263

63-
/**
64-
* @dataProvider provideRequests
65-
*/
64+
#[DataProvider('provideRequests')]
6665
public function testSignsRequests($rawRequest, $rawExpected)
6766
{
6867
$request = $this->parseRequest($rawRequest);
@@ -140,9 +139,7 @@ public static function provideRequests()
140139
];
141140
}
142141

143-
/**
144-
* @dataProvider provideRequestsWithQueryParams
145-
*/
142+
#[DataProvider('provideRequestsWithQueryParams')]
146143
public function testSignsRequestsWithArrayInQueryParams($rawRequestWithoutQuery, $rawExpected, $queryParams)
147144
{
148145
$request = $this->parseRequest($rawRequestWithoutQuery, $queryParams);

tests/Unit/Stream/CallableStreamTest.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,43 @@
55
namespace AsyncAws\Core\Tests\Unit\Stream;
66

77
use AsyncAws\Core\Stream\CallableStream;
8+
use PHPUnit\Framework\Attributes\DataProvider;
89
use PHPUnit\Framework\TestCase;
910

1011
class CallableStreamTest extends TestCase
1112
{
12-
/**
13-
* @dataProvider provideLengths
14-
*/
13+
#[DataProvider('provideLengths')]
1514
public function testLength(callable $content, ?int $expected): void
1615
{
1716
$stream = CallableStream::create($content);
1817

1918
self::assertSame($expected, $stream->length());
2019
}
2120

22-
/**
23-
* @dataProvider provideStrings
24-
*/
21+
#[DataProvider('provideStrings')]
2522
public function testStringify(callable $content, string $expected): void
2623
{
2724
$stream = CallableStream::create($content);
2825

2926
self::assertSame($expected, $stream->stringify());
3027
}
3128

32-
/**
33-
* @dataProvider provideChunks
34-
*/
29+
#[DataProvider('provideChunks')]
3530
public function testChunk(callable $content, array $expected): void
3631
{
3732
$stream = CallableStream::create($content);
3833

3934
self::assertSame($expected, iterator_to_array($stream));
4035
}
4136

42-
public function provideLengths(): iterable
37+
public static function provideLengths(): iterable
4338
{
4439
yield [function () {
4540
return 'Hello world';
4641
}, null];
4742
}
4843

49-
public function provideStrings(): iterable
44+
public static function provideStrings(): iterable
5045
{
5146
$f = static function (string ...$items) {
5247
return static function () use (&$items) {
@@ -58,7 +53,7 @@ public function provideStrings(): iterable
5853
yield [$f('Hello', ' ', '', 'world'), 'Hello '];
5954
}
6055

61-
public function provideChunks(): iterable
56+
public static function provideChunks(): iterable
6257
{
6358
$f = static function (string ...$items) {
6459
return static function () use (&$items) {

tests/Unit/Stream/FixedSizeStreamTest.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,63 +9,56 @@
99
use AsyncAws\Core\Stream\IterableStream;
1010
use AsyncAws\Core\Stream\RequestStream;
1111
use AsyncAws\Core\Stream\StringStream;
12+
use PHPUnit\Framework\Attributes\DataProvider;
1213
use PHPUnit\Framework\TestCase;
1314

1415
class FixedSizeStreamTest extends TestCase
1516
{
16-
/**
17-
* @dataProvider provideLengths
18-
*/
17+
#[DataProvider('provideLengths')]
1918
public function testLength(RequestStream $content, ?int $expected): void
2019
{
2120
$stream = FixedSizeStream::create($content);
2221

2322
self::assertSame($expected, $stream->length());
2423
}
2524

26-
/**
27-
* @dataProvider provideStrings
28-
*/
25+
#[DataProvider('provideStrings')]
2926
public function testStringify(RequestStream $content, string $expected): void
3027
{
3128
$stream = FixedSizeStream::create($content);
3229

3330
self::assertSame($expected, $stream->stringify());
3431
}
3532

36-
/**
37-
* @dataProvider provideChunks
38-
*/
33+
#[DataProvider('provideChunks')]
3934
public function testChunk(RequestStream $content, int $size, array $expected): void
4035
{
4136
$stream = FixedSizeStream::create($content, $size);
4237

4338
self::assertSame($expected, iterator_to_array($stream));
4439
}
4540

46-
/**
47-
* @dataProvider provideChunks
48-
*/
41+
#[DataProvider('provideChunks')]
4942
public function testDecoratingFixedSize(RequestStream $content, int $size, array $expected): void
5043
{
5144
$stream = FixedSizeStream::create(FixedSizeStream::create($content, 5), $size);
5245

5346
self::assertSame($expected, iterator_to_array($stream));
5447
}
5548

56-
public function provideLengths(): iterable
49+
public static function provideLengths(): iterable
5750
{
5851
yield [StringStream::create('Hello world'), 11];
5952
yield [CallableStream::create(function () {}), null];
6053
}
6154

62-
public function provideStrings(): iterable
55+
public static function provideStrings(): iterable
6356
{
6457
yield [StringStream::create('Hello world'), 'Hello world'];
6558
yield [IterableStream::create((function () { yield 'Hello world'; })()), 'Hello world'];
6659
}
6760

68-
public function provideChunks(): iterable
61+
public static function provideChunks(): iterable
6962
{
7063
yield [StringStream::create('Hello world'), 3, ['Hel', 'lo ', 'wor', 'ld']];
7164
yield [IterableStream::create((function () {

tests/Unit/Stream/IterableStreamTest.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,43 @@
55
namespace AsyncAws\Core\Tests\Unit\Stream;
66

77
use AsyncAws\Core\Stream\IterableStream;
8+
use PHPUnit\Framework\Attributes\DataProvider;
89
use PHPUnit\Framework\TestCase;
910

1011
class IterableStreamTest extends TestCase
1112
{
12-
/**
13-
* @dataProvider provideLengths
14-
*/
13+
#[DataProvider('provideLengths')]
1514
public function testLength(iterable $content, ?int $expected): void
1615
{
1716
$stream = IterableStream::create($content);
1817

1918
self::assertSame($expected, $stream->length());
2019
}
2120

22-
/**
23-
* @dataProvider provideStrings
24-
*/
21+
#[DataProvider('provideStrings')]
2522
public function testStringify(iterable $content, string $expected): void
2623
{
2724
$stream = IterableStream::create($content);
2825

2926
self::assertSame($expected, $stream->stringify());
3027
}
3128

32-
/**
33-
* @dataProvider provideChunks
34-
*/
29+
#[DataProvider('provideChunks')]
3530
public function testChunk(iterable $content, array $expected): void
3631
{
3732
$stream = IterableStream::create($content);
3833

3934
self::assertSame($expected, iterator_to_array($stream));
4035
}
4136

42-
public function provideLengths(): iterable
37+
public static function provideLengths(): iterable
4338
{
4439
yield [(function () {
4540
yield 'Hello world';
4641
})(), null];
4742
}
4843

49-
public function provideStrings(): iterable
44+
public static function provideStrings(): iterable
5045
{
5146
yield [(function () {
5247
yield 'Hello world';
@@ -65,7 +60,7 @@ public function provideStrings(): iterable
6560
})(), 'Hello world'];
6661
}
6762

68-
public function provideChunks(): iterable
63+
public static function provideChunks(): iterable
6964
{
7065
yield [(function () {
7166
yield 'Hello world';

0 commit comments

Comments
 (0)