Skip to content

Commit 19a0054

Browse files
authored
Merge pull request #66 from clue-labs/phpunit7
Test against PHP7.2 and PHP 7.3, improve HHVM compatibility and add forward compatibility with PHPUnit 7
2 parents 3534ecc + 6a8c8bc commit 19a0054

5 files changed

Lines changed: 23 additions & 14 deletions

File tree

.travis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ php:
77
- 5.6
88
- 7.0
99
- 7.1
10-
- hhvm # ignore errors, see below
10+
- 7.2
11+
- 7.3
12+
# - hhvm # requires legacy phpunit & ignore errors, see below
1113

1214
# lock distro so new future defaults will not break the build
1315
dist: trusty
@@ -16,14 +18,16 @@ matrix:
1618
include:
1719
- php: 5.3
1820
dist: precise
21+
- php: hhvm
22+
install: composer require phpunit/phpunit:^5 --dev --no-interaction
1923
allow_failures:
2024
- php: hhvm
2125

2226
sudo: false
2327

2428
install:
2529
- composer install --no-interaction
26-
30+
2731
script:
2832
- vendor/bin/phpunit --coverage-text
2933
- php examples/13-benchmark-throughput.php

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"react/stream": "^1.0 || ^0.7.6"
1111
},
1212
"require-dev": {
13-
"phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35",
13+
"phpunit/phpunit": "^7.0 || ^6.4 || ^5.7 || ^4.8.35",
1414
"sebastian/environment": "^3.0 || ^2.0 || ^1.0"
1515
},
1616
"autoload": {

phpunit.xml.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
bootstrap="vendor/autoload.php"
1312
>
1413
<testsuites>

src/Process.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ public function start(LoopInterface $loop, $interval = 0.1)
180180
}
181181

182182
foreach ($pipes as $n => $fd) {
183-
$meta = \stream_get_meta_data($fd);
184-
if (\strpos($meta['mode'], 'w') !== false) {
183+
if (\strpos($this->fds[$n][1], 'w') === false) {
185184
$stream = new WritableResourceStream($fd, $loop);
186185
} else {
187186
$stream = new ReadableResourceStream($fd, $loop);

tests/AbstractProcessTest.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,13 @@ public function testDetectsClosingStdoutWithoutHavingToWaitForExit()
308308
$process->start($loop);
309309

310310
$closed = false;
311-
$process->stdout->on('close', function () use (&$closed) {
311+
$process->stdout->on('close', function () use (&$closed, $loop) {
312312
$closed = true;
313+
$loop->stop();
313314
});
314315

315-
// run loop for 0.1s only
316-
$loop->addTimer(0.1, function () use ($loop) {
316+
// run loop for maximum of 0.5s only
317+
$loop->addTimer(0.5, function () use ($loop) {
317318
$loop->stop();
318319
});
319320
$loop->run();
@@ -330,15 +331,21 @@ public function testKeepsRunningEvenWhenAllStdioPipesHaveBeenClosed()
330331
$process->start($loop);
331332

332333
$closed = 0;
333-
$process->stdout->on('close', function () use (&$closed) {
334+
$process->stdout->on('close', function () use (&$closed, $loop) {
334335
++$closed;
336+
if ($closed === 2) {
337+
$loop->stop();
338+
}
335339
});
336-
$process->stderr->on('close', function () use (&$closed) {
340+
$process->stderr->on('close', function () use (&$closed, $loop) {
337341
++$closed;
342+
if ($closed === 2) {
343+
$loop->stop();
344+
}
338345
});
339346

340-
// run loop for 0.1s only
341-
$loop->addTimer(0.1, function () use ($loop) {
347+
// run loop for maximum 0.5s only
348+
$loop->addTimer(0.5, function () use ($loop) {
342349
$loop->stop();
343350
});
344351
$loop->run();
@@ -359,7 +366,7 @@ public function testDetectsClosingProcessEvenWhenAllStdioPipesHaveBeenClosed()
359366
$loop->run();
360367
$time = microtime(true) - $time;
361368

362-
$this->assertLessThan(0.1, $time);
369+
$this->assertLessThan(0.5, $time);
363370
$this->assertSame(0, $process->getExitCode());
364371
}
365372

0 commit comments

Comments
 (0)