Skip to content

Commit 4516acc

Browse files
authored
Migrate the testsuite to PHPUnit 11 (#1977)
1 parent 525daa7 commit 4516acc

File tree

4 files changed

+47
-28
lines changed

4 files changed

+47
-28
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ jobs:
2828
- name: Download dependencies
2929
run: |
3030
composer config minimum-stability dev
31-
composer req symfony/phpunit-bridge --no-update
3231
composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable
3332
3433
- name: Run tests
35-
run: ./vendor/bin/simple-phpunit
34+
run: ./vendor/bin/phpunit

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"php": "^8.2",
1616
"async-aws/dynamo-db": "^1.0 || ^2.0 || ^3.0"
1717
},
18+
"require-dev": {
19+
"phpunit/phpunit": "^11.5.42",
20+
"symfony/error-handler": "^7.3.2 || ^8.0",
21+
"symfony/phpunit-bridge": "^7.3.2 || ^8.0"
22+
},
1823
"autoload": {
1924
"psr-4": {
2025
"AsyncAws\\DynamoDbSession\\": "src"

phpunit.xml.dist

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
44
backupGlobals="false"
55
colors="true"
66
bootstrap="vendor/autoload.php"
77
failOnRisky="true"
88
failOnWarning="true"
9+
failOnDeprecation="true"
10+
failOnNotice="true"
911
>
10-
<coverage>
12+
<source ignoreSuppressionOfDeprecations="true">
1113
<include>
1214
<directory>./src</directory>
1315
</include>
14-
</coverage>
16+
<deprecationTrigger>
17+
<function>trigger_deprecation</function>
18+
</deprecationTrigger>
19+
</source>
1520
<php>
1621
<ini name="error_reporting" value="-1"/>
1722
</php>
@@ -20,4 +25,7 @@
2025
<directory>./tests/</directory>
2126
</testsuite>
2227
</testsuites>
28+
<extensions>
29+
<bootstrap class="Symfony\Bridge\PhpUnit\SymfonyExtension"/>
30+
</extensions>
2331
</phpunit>

tests/SessionHandlerTest.php

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -181,35 +181,42 @@ public function testWriteTwice()
181181
->willReturn(ResultMockFactory::create(GetItemOutput::class, [
182182
'Item' => [
183183
'data' => new AttributeValue(['S' => 'previous data']),
184-
'expires' => new AttributeValue(['N' => time() + 86400]),
184+
'expires' => new AttributeValue(['N' => (string) (time() + 86400)]),
185185
],
186186
]));
187187

188+
$expectedFirstData = [
189+
'TableName' => 'testTable',
190+
'Key' => [
191+
'id' => ['S' => 'PHPSESSID_123456789'],
192+
],
193+
'AttributeUpdates' => [
194+
'expires' => ['Value' => ['N' => (string) (time() + 86400)]],
195+
'data' => ['Value' => ['S' => 'new data']],
196+
],
197+
];
198+
$expectedSecondData = [
199+
'TableName' => 'testTable',
200+
'Key' => [
201+
'id' => ['S' => 'PHPSESSID_123456789'],
202+
],
203+
'AttributeUpdates' => [
204+
'expires' => ['Value' => ['N' => (string) (time() + 86400)]],
205+
'data' => ['Value' => ['S' => 'previous data']],
206+
],
207+
];
208+
188209
$this->client
189210
->expects(self::exactly(2))
190211
->method('updateItem')
191-
->withConsecutive(
192-
[self::equalTo([
193-
'TableName' => 'testTable',
194-
'Key' => [
195-
'id' => ['S' => 'PHPSESSID_123456789'],
196-
],
197-
'AttributeUpdates' => [
198-
'expires' => ['Value' => ['N' => time() + 86400]],
199-
'data' => ['Value' => ['S' => 'new data']],
200-
],
201-
], 10)],
202-
[self::equalTo([
203-
'TableName' => 'testTable',
204-
'Key' => [
205-
'id' => ['S' => 'PHPSESSID_123456789'],
206-
],
207-
'AttributeUpdates' => [
208-
'expires' => ['Value' => ['N' => time() + 86400]],
209-
'data' => ['Value' => ['S' => 'previous data']],
210-
],
211-
], 10)]
212-
);
212+
->with(self::callback(function (array $data) use ($expectedFirstData, $expectedSecondData): bool {
213+
static $i = 0;
214+
215+
return match (++$i) {
216+
1 => $data === $expectedFirstData,
217+
2 => $data === $expectedSecondData,
218+
};
219+
}));
213220

214221
$this->handler->read('123456789');
215222
$this->handler->write('123456789', 'new data');

0 commit comments

Comments
 (0)