Skip to content

Commit 749f8c7

Browse files
committed
Run tests on PHP 8.5 and update test environment
1 parent a07c446 commit 749f8c7

File tree

6 files changed

+357
-124
lines changed

6 files changed

+357
-124
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
rdbms:
1414
- mysql:5
1515
php:
16+
- 8.5
1617
- 8.4
1718
- 8.3
1819
- 8.2
@@ -27,14 +28,14 @@ jobs:
2728
- 5.5
2829
- 5.4
2930
include:
30-
- php: 8.4
31+
- php: 8.5
3132
rdbms: mysql:9
32-
- php: 8.4
33+
- php: 8.5
3334
rdbms: mysql:8
34-
- php: 8.4
35+
- php: 8.5
3536
rdbms: mariadb:10
3637
steps:
37-
- uses: actions/checkout@v4
38+
- uses: actions/checkout@v6
3839
- uses: shivammathur/setup-php@v2
3940
with:
4041
php-version: ${{ matrix.php }}
@@ -53,7 +54,7 @@ jobs:
5354
runs-on: ubuntu-24.04
5455
continue-on-error: true
5556
steps:
56-
- uses: actions/checkout@v4
57+
- uses: actions/checkout@v6
5758
- run: cp "$(which composer)" composer.phar && ./composer.phar self-update --2.2 # downgrade Composer for HHVM
5859
- name: Run hhvm composer.phar install
5960
uses: docker://hhvm/hhvm:3.30-lts-latest

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"require": {
77
"php": ">=5.4.0",
88
"evenement/evenement": "^3.0 || ^2.1 || ^1.1",
9-
"react/event-loop": "^1.2",
10-
"react/promise": "^3.2 || ^2.7",
9+
"react/event-loop": "^1.6",
10+
"react/promise": "^3.3 || ^2.7",
1111
"react/promise-stream": "^1.6",
1212
"react/promise-timer": "^1.11",
13-
"react/socket": "^1.16"
13+
"react/socket": "^1.17"
1414
},
1515
"require-dev": {
1616
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36",

examples/12-slow-stream.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
$stream = $mysql->queryStream($query);
1414

1515
$ref = new ReflectionProperty($mysql, 'connecting');
16-
$ref->setAccessible(true);
16+
if (PHP_VERSION_ID < 80100) {
17+
$ref->setAccessible(true);
18+
}
1719
$promise = $ref->getValue($mysql);
1820
assert($promise instanceof React\Promise\PromiseInterface);
1921

@@ -28,19 +30,25 @@
2830
try {
2931
// accept private "stream" (instanceof React\Socket\ConnectionInterface)
3032
$ref = new ReflectionProperty($connection, 'stream');
31-
$ref->setAccessible(true);
33+
if (PHP_VERSION_ID < 80100) {
34+
$ref->setAccessible(true);
35+
}
3236
$conn = $ref->getValue($connection);
3337
assert($conn instanceof React\Socket\ConnectionInterface);
3438

3539
// access private "input" (instanceof React\Stream\DuplexStreamInterface)
3640
$ref = new ReflectionProperty($conn, 'input');
37-
$ref->setAccessible(true);
41+
if (PHP_VERSION_ID < 80100) {
42+
$ref->setAccessible(true);
43+
}
3844
$stream = $ref->getValue($conn);
3945
assert($stream instanceof React\Stream\DuplexStreamInterface);
4046

4147
// reduce private bufferSize to just a few bytes to slow things down
4248
$ref = new ReflectionProperty($stream, 'bufferSize');
43-
$ref->setAccessible(true);
49+
if (PHP_VERSION_ID < 80100) {
50+
$ref->setAccessible(true);
51+
}
4452
$ref->setValue($stream, 8);
4553
} catch (Exception $e) {
4654
echo 'Warning: Unable to reduce buffer size: ' . $e->getMessage() . PHP_EOL;

tests/Io/FactoryTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ public function testConstructWithoutLoopAssignsLoopAutomatically()
1616
$factory = new Factory();
1717

1818
$ref = new \ReflectionProperty($factory, 'loop');
19-
$ref->setAccessible(true);
19+
if (PHP_VERSION_ID < 80100) {
20+
$ref->setAccessible(true);
21+
}
2022
$loop = $ref->getValue($factory);
2123

2224
$this->assertInstanceOf('React\EventLoop\LoopInterface', $loop);

tests/Io/ParserTest.php

Lines changed: 63 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public function testClosingStreamEmitsErrorForCurrentCommand()
3131

3232
// hack to inject command as current command
3333
$ref = new \ReflectionProperty($parser, 'currCommand');
34-
$ref->setAccessible(true);
34+
if (PHP_VERSION_ID < 80100) {
35+
$ref->setAccessible(true);
36+
}
3537
$ref->setValue($parser, $command);
3638

3739
$stream->close();
@@ -62,7 +64,9 @@ public function testParseValidAuthPluginWillSendAuthResponse()
6264
$stream->write("\x49\0\0\0\x0a\x38\x2e\x34\x2e\x35\0\x5e\0\0\0\x08\x0c\x41\x44\x12\x5e\x69\x59\0\xff\xff\xff\x02\0\xff\xdf\x15\0\0\0\0\0\0\0\0\0\0\x3c\x2c\x5e\x54\x06\x04\x01\x61\x01\x20\x79\x1b\0\x63\x61\x63\x68\x69\x6e\x67\x5f\x73\x68\x61\x32\x5f\x70\x61\x73\x73\x77\x6f\x72\x64\0");
6365

6466
$ref = new \ReflectionProperty($parser, 'authPlugin');
65-
$ref->setAccessible(true);
67+
if (PHP_VERSION_ID < 80100) {
68+
$ref->setAccessible(true);
69+
}
6670
$this->assertEquals('caching_sha2_password', $ref->getValue($parser));
6771
}
6872

@@ -100,11 +104,15 @@ public function testParseAuthSwitchRequestWillSendAuthSwitchResponsePacket()
100104
$parser->start();
101105

102106
$ref = new \ReflectionProperty($parser, 'phase');
103-
$ref->setAccessible(true);
107+
if (PHP_VERSION_ID < 80100) {
108+
$ref->setAccessible(true);
109+
}
104110
$ref->setValue($parser, Parser::PHASE_AUTH_SENT);
105111

106112
$ref = new \ReflectionProperty($parser, 'currCommand');
107-
$ref->setAccessible(true);
113+
if (PHP_VERSION_ID < 80100) {
114+
$ref->setAccessible(true);
115+
}
108116
$ref->setValue($parser, $command);
109117

110118
$stream->write("\x20\0\0\0" . "\xfe" . "caching_sha2_password" . "\0" . "scramble" . "\0");
@@ -127,11 +135,15 @@ public function testParseAuthSwitchRequestWithUnexpectedAuthPluginWillEmitErrorA
127135
$parser->start();
128136

129137
$ref = new \ReflectionProperty($parser, 'phase');
130-
$ref->setAccessible(true);
138+
if (PHP_VERSION_ID < 80100) {
139+
$ref->setAccessible(true);
140+
}
131141
$ref->setValue($parser, Parser::PHASE_AUTH_SENT);
132142

133143
$ref = new \ReflectionProperty($parser, 'currCommand');
134-
$ref->setAccessible(true);
144+
if (PHP_VERSION_ID < 80100) {
145+
$ref->setAccessible(true);
146+
}
135147
$ref->setValue($parser, $command);
136148

137149
$stream->write("\x19\0\0\0" . "\xfe" . "sha256_password" . "\0" . "scramble" . "\0");
@@ -151,15 +163,21 @@ public function testParseAuthMoreDataWithFastAuthSuccessWillPrintDebugLogAndWait
151163
$parser->start();
152164

153165
$ref = new \ReflectionProperty($parser, 'debug');
154-
$ref->setAccessible(true);
166+
if (PHP_VERSION_ID < 80100) {
167+
$ref->setAccessible(true);
168+
}
155169
$ref->setValue($parser, true);
156170

157171
$ref = new \ReflectionProperty($parser, 'phase');
158-
$ref->setAccessible(true);
172+
if (PHP_VERSION_ID < 80100) {
173+
$ref->setAccessible(true);
174+
}
159175
$ref->setValue($parser, Parser::PHASE_AUTH_SENT);
160176

161177
$ref = new \ReflectionProperty($parser, 'authPlugin');
162-
$ref->setAccessible(true);
178+
if (PHP_VERSION_ID < 80100) {
179+
$ref->setAccessible(true);
180+
}
163181
$ref->setValue($parser, 'caching_sha2_password');
164182

165183
$this->expectOutputRegex('/Fast auth success\n$/');
@@ -180,11 +198,15 @@ public function testParseAuthMoreDataWithFastAuthFailureWillSendCertificateReque
180198
$parser->start();
181199

182200
$ref = new \ReflectionProperty($parser, 'phase');
183-
$ref->setAccessible(true);
201+
if (PHP_VERSION_ID < 80100) {
202+
$ref->setAccessible(true);
203+
}
184204
$ref->setValue($parser, Parser::PHASE_AUTH_SENT);
185205

186206
$ref = new \ReflectionProperty($parser, 'authPlugin');
187-
$ref->setAccessible(true);
207+
if (PHP_VERSION_ID < 80100) {
208+
$ref->setAccessible(true);
209+
}
188210
$ref->setValue($parser, 'caching_sha2_password');
189211

190212
$stream->write("\x02\0\0\0" . "\x01\x04");
@@ -207,15 +229,21 @@ public function testParseAuthMoreDataWithCertificateWillSendEncryptedPassword()
207229
$parser->start();
208230

209231
$ref = new \ReflectionProperty($parser, 'phase');
210-
$ref->setAccessible(true);
232+
if (PHP_VERSION_ID < 80100) {
233+
$ref->setAccessible(true);
234+
}
211235
$ref->setValue($parser, Parser::PHASE_AUTH_SENT);
212236

213237
$ref = new \ReflectionProperty($parser, 'authPlugin');
214-
$ref->setAccessible(true);
238+
if (PHP_VERSION_ID < 80100) {
239+
$ref->setAccessible(true);
240+
}
215241
$ref->setValue($parser, 'caching_sha2_password');
216242

217243
$ref = new \ReflectionProperty($parser, 'currCommand');
218-
$ref->setAccessible(true);
244+
if (PHP_VERSION_ID < 80100) {
245+
$ref->setAccessible(true);
246+
}
219247
$ref->setValue($parser, $command);
220248

221249
$stream->write("\x04\0\0\0" . "\x01---");
@@ -239,15 +267,21 @@ public function testParseAuthMoreDataWithCertificateWillEmitErrorAndCloseConnect
239267
$parser->start();
240268

241269
$ref = new \ReflectionProperty($parser, 'phase');
242-
$ref->setAccessible(true);
270+
if (PHP_VERSION_ID < 80100) {
271+
$ref->setAccessible(true);
272+
}
243273
$ref->setValue($parser, Parser::PHASE_AUTH_SENT);
244274

245275
$ref = new \ReflectionProperty($parser, 'authPlugin');
246-
$ref->setAccessible(true);
276+
if (PHP_VERSION_ID < 80100) {
277+
$ref->setAccessible(true);
278+
}
247279
$ref->setValue($parser, 'caching_sha2_password');
248280

249281
$ref = new \ReflectionProperty($parser, 'currCommand');
250-
$ref->setAccessible(true);
282+
if (PHP_VERSION_ID < 80100) {
283+
$ref->setAccessible(true);
284+
}
251285
$ref->setValue($parser, $command);
252286

253287
$stream->write("\x04\0\0\0" . "\x01---");
@@ -352,11 +386,15 @@ public function testReceivingErrorFrameForQueryAfterResultSetHeadersShouldEmitEr
352386
$this->assertEquals('Query execution was interrupted', $error->getMessage());
353387

354388
$ref = new \ReflectionProperty($parser, 'rsState');
355-
$ref->setAccessible(true);
389+
if (PHP_VERSION_ID < 80100) {
390+
$ref->setAccessible(true);
391+
}
356392
$this->assertEquals(0, $ref->getValue($parser));
357393

358394
$ref = new \ReflectionProperty($parser, 'resultFields');
359-
$ref->setAccessible(true);
395+
if (PHP_VERSION_ID < 80100) {
396+
$ref->setAccessible(true);
397+
}
360398
$this->assertEquals([], $ref->getValue($parser));
361399
}
362400

@@ -380,7 +418,9 @@ public function testReceivingInvalidPacketWithMissingDataShouldEmitErrorAndClose
380418

381419
// hack to inject command as current command
382420
$ref = new \ReflectionProperty($parser, 'currCommand');
383-
$ref->setAccessible(true);
421+
if (PHP_VERSION_ID < 80100) {
422+
$ref->setAccessible(true);
423+
}
384424
$ref->setValue($parser, $command);
385425

386426
$stream->on('close', $this->expectCallableOnce());
@@ -413,7 +453,9 @@ public function testReceivingInvalidPacketWithExcessiveDataShouldEmitErrorAndClo
413453

414454
// hack to inject command as current command
415455
$ref = new \ReflectionProperty($parser, 'currCommand');
416-
$ref->setAccessible(true);
456+
if (PHP_VERSION_ID < 80100) {
457+
$ref->setAccessible(true);
458+
}
417459
$ref->setValue($parser, $command);
418460

419461
$stream->on('close', $this->expectCallableOnce());

0 commit comments

Comments
 (0)