Skip to content

Commit 1510f83

Browse files
chore: phpunit 10 support (#3242)
1 parent fb74a2d commit 1510f83

277 files changed

Lines changed: 4360 additions & 5141 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"type": "enhancement",
4+
"category": "",
5+
"description": "Add support for PHPUnit v10. \n- Make data provider static functions. \n- Use class attributes instead of annotations for @dataProvider, @covers, and @doesNotPerformAssertions. \n- Remove/Replace the usage of expectDeprecation, expectDeprecationMessage, expectDeprecationMessageMatches, expectError, expectErrorMessage, expectNotice, expectNoticeMessage, expectWarning, and expectWarningMessage. \n- Migrate phpunit xml config file."
6+
}
7+
]

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
composer update ${{ matrix.composer-options }} --no-interaction --prefer-dist --with-all-dependencies
7272
composer update psr/http-message guzzlehttp/psr7 guzzlehttp/guzzle --with-all-dependencies --no-interaction
7373
if [[ "${{ matrix.php-versions }}" == "8.4" ]]; then
74-
composer update phpunit/phpunit:^9.6.18 --with-all-dependencies --no-interaction
74+
composer update phpunit/phpunit:^10.0 --with-all-dependencies --no-interaction
7575
fi
7676
else
7777
composer update ${{ matrix.composer-options }} --no-interaction --prefer-dist --with-all-dependencies

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ clear-cache:
2424
php build/aws-clear-cache.php
2525

2626
test:
27-
@AWS_ACCESS_KEY_ID=foo AWS_SECRET_ACCESS_KEY=bar AWS_SESSION_TOKEN= AWS_CSM_ENABLED=false AWS_REGION= AWS_ENDPOINT_URL= AWS_SUPPRESS_PHP_DEPRECATION_WARNING=true \
28-
vendor/bin/phpunit --testsuite=unit $(TEST)
27+
AWS_ACCESS_KEY_ID=foo AWS_SECRET_ACCESS_KEY=bar AWS_SESSION_TOKEN= \
28+
AWS_CSM_ENABLED=false \
29+
AWS_REGION= \
30+
AWS_ENDPOINT_URL= \
31+
AWS_SUPPRESS_PHP_DEPRECATION_WARNING=true \
32+
vendor/bin/phpunit --no-coverage --testsuite=unit $(TEST)
2933

3034
test-phar: package
3135
[ -f build/artifacts/behat.phar ] || (cd build/artifacts && \

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"ext-openssl": "*",
3434
"ext-dom": "*",
3535
"ext-sockets": "*",
36-
"phpunit/phpunit": "^9.6",
36+
"phpunit/phpunit": "^10.0",
3737
"behat/behat": "~3.0",
3838
"doctrine/cache": "~1.4",
3939
"aws/aws-php-sns-message-validator": "~1.0",
@@ -42,7 +42,7 @@
4242
"psr/simple-cache": "^2.0 || ^3.0",
4343
"sebastian/comparator": "^1.2.3 || ^4.0 || ^5.0",
4444
"yoast/phpunit-polyfills": "^2.0",
45-
"dms/phpunit-arraysubset-asserts": "^0.4.0"
45+
"dms/phpunit-arraysubset-asserts": "^v0.5.0"
4646
},
4747
"suggest": {
4848
"ext-openssl": "Allows working with CloudFront private distributions and verifying received SNS messages",

features/bootstrap/Aws/Test/Integ/BatchingContext.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@
99
use Aws\Sqs\SqsClient;
1010
use Behat\Behat\Hook\Scope\AfterFeatureScope;
1111
use Behat\Behat\Hook\Scope\BeforeFeatureScope;
12-
use Behat\Behat\Tester\Exception\PendingException;
1312
use Behat\Behat\Context\Context;
1413
use Behat\Behat\Context\SnippetAcceptingContext;
15-
use Behat\Gherkin\Node\PyStringNode;
16-
use Behat\Gherkin\Node\TableNode;
1714
use PHPUnit\Framework\Assert;
18-
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
1915

20-
class BatchingContext extends TestCase implements
16+
class BatchingContext implements
2117
Context,
2218
SnippetAcceptingContext
2319
{
@@ -163,15 +159,15 @@ public function itemsShouldHaveBeenWritten($itemCount)
163159
'TableName' => self::$resource,
164160
]);
165161

166-
$this->assertSame((int) $itemCount, iterator_count($actualItems));
162+
Assert::assertSame((int) $itemCount, iterator_count($actualItems));
167163
}
168164

169165
/**
170166
* @Then /^the batch should have been flushed at least (\d+) times$/
171167
*/
172168
public function theBatchShouldHaveBeenFlushedTimes($flushCount)
173169
{
174-
$this->assertGreaterThanOrEqual((int) $flushCount, $this->flushCount);
170+
Assert::assertGreaterThanOrEqual((int) $flushCount, $this->flushCount);
175171
}
176172

177173
/**
@@ -230,6 +226,6 @@ public function messagesShouldHaveBeenDeletedFromTheQueue($messageCount)
230226
? count($this->response['Successful'])
231227
: 0;
232228

233-
$this->assertSame((int) $messageCount, $failedCount + $successfulCount);
229+
Assert::assertSame((int) $messageCount, $failedCount + $successfulCount);
234230
}
235231
}

features/bootstrap/Aws/Test/Integ/BlockingContext.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,15 @@
44

55
use Aws\AwsClient;
66
use Aws\DynamoDb\Exception\DynamoDbException;
7-
use Behat\Behat\Hook\Scope\AfterFeatureScope;
8-
use Behat\Behat\Tester\Exception\PendingException;
97
use Behat\Behat\Context\Context;
108
use Behat\Behat\Context\SnippetAcceptingContext;
11-
use Behat\Gherkin\Node\PyStringNode;
12-
use Behat\Gherkin\Node\TableNode;
139
use GuzzleHttp\Promise;
1410
use PHPUnit\Framework\Assert;
15-
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
1611

1712
/**
1813
* Defines application features from the specific context.
1914
*/
20-
class BlockingContext extends TestCase implements Context, SnippetAcceptingContext
15+
class BlockingContext implements Context, SnippetAcceptingContext
2116
{
2217
use IntegUtils;
2318

@@ -101,9 +96,9 @@ public function theTableNamedWillNotExist($table)
10196
{
10297
try {
10398
$this->theTableNamedWillExist($table);
104-
$this->fail("$table exists but should not.");
99+
Assert::fail("$table exists but should not.");
105100
} catch (DynamoDbException $e) {
106-
$this->assertSame('ResourceNotFoundException', $e->getAwsErrorCode());
101+
Assert::assertSame('ResourceNotFoundException', $e->getAwsErrorCode());
107102
}
108103
}
109104

features/bootstrap/Aws/Test/Integ/ClientSideMonitoringContext.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
use GuzzleHttp\Psr7\Request;
2020
use GuzzleHttp\Psr7\Response;
2121
use PHPUnit\Framework\Assert;
22-
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
2322

24-
class ClientSideMonitoringContext extends TestCase
23+
class ClientSideMonitoringContext
2524
implements Context, SnippetAcceptingContext
2625
{
2726

@@ -271,19 +270,19 @@ private function clearAndSetEnv($env)
271270

272271
private function compareMonitoringEvents($expected, $actual)
273272
{
274-
$this->assertSame(count($expected), count($actual));
273+
Assert::assertSame(count($expected), count($actual));
275274
foreach ($expected as $index => $expectedEvent) {
276275
$actualEvent = $actual[$index];
277276
foreach ($expectedEvent as $key => $value) {
278-
$this->assertArrayHasKey($key, $actualEvent);
277+
Assert::assertArrayHasKey($key, $actualEvent);
279278
$this->validateEventValue($value, $actualEvent[$key]);
280279
}
281280
$allowedFields = array_merge(
282281
array_keys($expectedEvent),
283282
array_keys($this->testData['defaults']['optionalEventFields'][$actualEvent['Type']])
284283
);
285284
foreach ($actualEvent as $key => $value) {
286-
$this->assertTrue(in_array($key, $allowedFields));
285+
Assert::assertTrue(in_array($key, $allowedFields));
287286
if (in_array($key, $this->testData['defaults']['optionalEventFields'][$actualEvent['Type']])) {
288287
$this->validateEventValue(
289288
$this->testData['defaults']['optionalEventFields'][$actualEvent['Type']],
@@ -437,13 +436,13 @@ private function validateEventValue($expected, $actual)
437436
{
438437
switch ($expected) {
439438
case "ANY_INT":
440-
$this->assertIsInt($actual);
439+
Assert::assertIsInt($actual);
441440
break;
442441
case "ANY_STR":
443-
$this->assertIsString('string', $actual);
442+
Assert::assertIsString('string', $actual);
444443
break;
445444
default:
446-
$this->assertEquals($expected, $actual);
445+
Assert::assertEquals($expected, $actual);
447446
}
448447
}
449448
}

features/bootstrap/Aws/Test/Integ/ConcurrencyContext.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,22 @@
44

55
use Aws\CommandInterface;
66
use Aws\CommandPool;
7-
use Aws\Exception\AwsException;
87
use Aws\Result;
98
use Aws\S3\S3Client;
109
use Behat\Behat\Hook\Scope\AfterFeatureScope;
1110
use Behat\Behat\Hook\Scope\BeforeFeatureScope;
12-
use Behat\Behat\Tester\Exception\PendingException;
1311
use Behat\Behat\Context\Context;
1412
use Behat\Behat\Context\SnippetAcceptingContext;
15-
use Behat\Gherkin\Node\PyStringNode;
1613
use Behat\Gherkin\Node\TableNode;
1714
use GuzzleHttp\Promise;
1815
use GuzzleHttp\Promise\PromiseInterface;
1916
use JmesPath;
2017
use PHPUnit\Framework\Assert;
21-
use PHPUnit\Framework\TestCase;
2218

2319
/**
2420
* Defines application features from the specific context.
2521
*/
26-
class ConcurrencyContext extends TestCase implements
22+
class ConcurrencyContext implements
2723
Context,
2824
SnippetAcceptingContext
2925
{
@@ -93,9 +89,12 @@ public function iCallTheApi($command)
9389
*/
9490
public function theValueAtShouldBeA($key, $type)
9591
{
96-
$this->assertInstanceOf(Result::class, $this->result);
92+
Assert::assertInstanceOf(Result::class, $this->result);
9793
$methodName = 'assertIs' . ucfirst($type);
98-
$this->$methodName($this->result->search($key));
94+
call_user_func(
95+
[Assert::class, $methodName],
96+
$this->result->search($key)
97+
);
9998
}
10099

101100
/**
@@ -161,15 +160,15 @@ public function iSendTheCommandsAsABatchTo($service)
161160
*/
162161
public function thereShouldBeResults($count)
163162
{
164-
$this->assertCount((int) $count, $this->result);
163+
Assert::assertCount((int) $count, $this->result);
165164
}
166165

167166
/**
168167
* @Then there should be :count value at :path
169168
*/
170169
public function thereShouldBeValueAt($count, $path)
171170
{
172-
$this->assertCount((int) $count, array_unique(
171+
Assert::assertCount((int) $count, array_unique(
173172
JmesPath\search($path, $this->result)
174173
));
175174
}

features/bootstrap/Aws/Test/Integ/MultipartContext.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88
use Aws\S3\MultipartCopy;
99
use Aws\S3\MultipartUploader as S3MultipartUploader;
1010
use Aws\S3\S3Client;
11-
use Behat\Behat\Tester\Exception\PendingException;
1211
use Aws\S3\BatchDelete;
1312
use Behat\Behat\Context\Context;
1413
use Behat\Behat\Context\SnippetAcceptingContext;
15-
use Behat\Gherkin\Node\PyStringNode;
16-
use Behat\Gherkin\Node\TableNode;
1714
use GuzzleHttp\Psr7;
1815
use GuzzleHttp\Psr7\NoSeekStream;
1916
use PHPUnit\Framework\Assert;

features/bootstrap/Aws/Test/Integ/NativeStreamContext.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@
55
use Aws\S3\S3Client;
66
use Behat\Behat\Hook\Scope\AfterFeatureScope;
77
use Behat\Behat\Hook\Scope\BeforeFeatureScope;
8-
use Behat\Behat\Tester\Exception\PendingException;
98
use Behat\Behat\Context\Context;
109
use Behat\Behat\Context\SnippetAcceptingContext;
11-
use Behat\Gherkin\Node\PyStringNode;
12-
use Behat\Gherkin\Node\TableNode;
1310
use PHPUnit\Framework\Assert;
14-
use PHPUnit\Framework\TestCase;
1511

1612
/**
1713
* Defines application features from the specific context.
1814
*/
19-
class NativeStreamContext extends TestCase implements
15+
class NativeStreamContext implements
2016
Context,
2117
SnippetAcceptingContext
2218
{
@@ -108,7 +104,7 @@ public function iCallOnThePath($method, $path)
108104
*/
109105
public function theCallShouldReturn($booleanString)
110106
{
111-
$this->assertSame(
107+
Assert::assertSame(
112108
filter_var($booleanString, FILTER_VALIDATE_BOOLEAN),
113109
$this->callSucceeded
114110
);
@@ -119,7 +115,7 @@ public function theCallShouldReturn($booleanString)
119115
*/
120116
public function iHaveAFileAtWithTheContent($path, $contents)
121117
{
122-
$this->assertGreaterThan(
118+
Assert::assertGreaterThan(
123119
0,
124120
file_put_contents($this->getS3Path($path), $contents)
125121
);
@@ -130,15 +126,15 @@ public function iHaveAFileAtWithTheContent($path, $contents)
130126
*/
131127
public function iHaveAFileAtWithNoContent($path)
132128
{
133-
$this->assertSame(0, file_put_contents($this->getS3Path($path), ''));
129+
Assert::assertSame(0, file_put_contents($this->getS3Path($path), ''));
134130
}
135131

136132
/**
137133
* @Then the file at :arg1 should contain :arg2
138134
*/
139135
public function theFileAtShouldContain($key, $contents)
140136
{
141-
$this->assertStringEqualsFile($this->getS3Path($key), $contents);
137+
Assert::assertStringEqualsFile($this->getS3Path($key), $contents);
142138
}
143139

144140
/**
@@ -154,23 +150,23 @@ public function iHaveAReadHandleOnTheFileAt($key)
154150
*/
155151
public function readingBytesShouldReturn($byteCount, $expected)
156152
{
157-
$this->assertSame($expected, fread($this->handle, $byteCount));
153+
Assert::assertSame($expected, fread($this->handle, $byteCount));
158154
}
159155

160156
/**
161157
* @Then /^calling fstat should report a size of (\d+)$/
162158
*/
163159
public function callingFstatShouldReportASizeOf($size)
164160
{
165-
$this->assertSame((int) $size, fstat($this->handle)['size']);
161+
Assert::assertSame((int) $size, fstat($this->handle)['size']);
166162
}
167163

168164
/**
169165
* @Then scanning the directory at :dir should return a list with one member named :file
170166
*/
171167
public function scanningTheDirectoryAtShouldReturnAListWithOneMemberNamed($dir, $file)
172168
{
173-
$this->assertSame([$file], scandir($this->getS3Path($dir)));
169+
Assert::assertSame([$file], scandir($this->getS3Path($dir)));
174170
}
175171

176172
private function getS3Path($path)

0 commit comments

Comments
 (0)