Skip to content

Commit 0f37290

Browse files
authored
Merge pull request #163 from clue-labs/2x-php7.4
Run tests on PHP 7.4 (backport to v2.x) and update PHPUnit test setup
2 parents 7c98fda + ac2b6a7 commit 0f37290

File tree

9 files changed

+33
-25
lines changed

9 files changed

+33
-25
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ php:
66
- 5.6
77
- 7.0
88
- 7.1
9+
- 7.2
10+
- 7.3
11+
- 7.4
912
- nightly # ignore errors, see below
1013
- hhvm # ignore errors, see below
1114

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"php": ">=5.4.0"
1010
},
1111
"require-dev": {
12-
"phpunit/phpunit": "~4.8"
12+
"phpunit/phpunit": "^7.0 || ^6.5 || ^5.7 || ^4.8.36"
1313
},
1414
"autoload": {
1515
"psr-4": {
@@ -19,7 +19,7 @@
1919
},
2020
"autoload-dev": {
2121
"psr-4": {
22-
"React\\Promise\\": "tests/fixtures"
22+
"React\\Promise\\": ["tests", "tests/fixtures"]
2323
}
2424
},
2525
"keywords": [

phpunit.xml.dist

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
12-
bootstrap="tests/bootstrap.php"
11+
bootstrap="vendor/autoload.php"
1312
>
1413
<testsuites>
1514
<testsuite name="Promise Test Suite">

tests/DeferredTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public function progressIsAnAliasForNotify()
4444
public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerRejectsWithException()
4545
{
4646
gc_collect_cycles();
47+
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
48+
4749
$deferred = new Deferred(function ($resolve, $reject) {
4850
$reject(new \Exception('foo'));
4951
});
@@ -57,6 +59,8 @@ public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerRejectsWithEx
5759
public function shouldRejectWithoutCreatingGarbageCyclesIfParentCancellerRejectsWithException()
5860
{
5961
gc_collect_cycles();
62+
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
63+
6064
$deferred = new Deferred(function ($resolve, $reject) {
6165
$reject(new \Exception('foo'));
6266
});

tests/FulfilledPromiseTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public function shouldThrowExceptionIfConstructedWithAPromise()
5252
public function shouldNotLeaveGarbageCyclesWhenRemovingLastReferenceToFulfilledPromiseWithAlwaysFollowers()
5353
{
5454
gc_collect_cycles();
55+
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
56+
5557
$promise = new FulfilledPromise(1);
5658
$promise->always(function () {
5759
throw new \RuntimeException();

tests/PromiseTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public function shouldRejectIfResolverThrowsException()
5252
public function shouldResolveWithoutCreatingGarbageCyclesIfResolverResolvesWithException()
5353
{
5454
gc_collect_cycles();
55+
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
56+
5557
$promise = new Promise(function ($resolve) {
5658
$resolve(new \Exception('foo'));
5759
});

tests/Stub/CallableStub.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/TestCase.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace React\Promise;
44

5-
class TestCase extends \PHPUnit_Framework_TestCase
5+
class TestCase extends \PHPUnit\Framework\TestCase
66
{
77
public function expectCallableExactly($amount)
88
{
@@ -36,8 +36,23 @@ public function expectCallableNever()
3636

3737
public function createCallableMock()
3838
{
39-
return $this
40-
->getMockBuilder('React\\Promise\Stub\CallableStub')
41-
->getMock();
39+
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
40+
}
41+
42+
public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null)
43+
{
44+
if (method_exists($this, 'expectException')) {
45+
// PHPUnit 5+
46+
$this->expectException($exception);
47+
if ($exceptionMessage !== '') {
48+
$this->expectExceptionMessage($exceptionMessage);
49+
}
50+
if ($exceptionCode !== null) {
51+
$this->expectExceptionCode($exceptionCode);
52+
}
53+
} else {
54+
// legacy PHPUnit 4
55+
parent::setExpectedException($exception, $exceptionMessage, $exceptionCode);
56+
}
4257
}
4358
}

tests/bootstrap.php

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)