Skip to content

Commit fa64326

Browse files
committed
Run tests on PHPUnit 9
1 parent 0bb8d4f commit fa64326

File tree

8 files changed

+36
-23
lines changed

8 files changed

+36
-23
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ install:
1515
- composer install --prefer-source
1616

1717
script:
18-
- phpunit -v --coverage-text
18+
- vendor/bin/phpunit --coverage-text

composer.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
"authors": [
66
{"name": "Jan Sorgalla", "email": "[email protected]"}
77
],
8-
"require": {
9-
"php": ">=5.3.3"
10-
},
118
"autoload": {
129
"psr-0": {
1310
"React\\Promise": "src/"
@@ -18,5 +15,11 @@
1815
"branch-alias": {
1916
"dev-master": "1.1-dev"
2017
}
18+
},
19+
"require": {
20+
"php": ">=5.3.3"
21+
},
22+
"require-dev": {
23+
"phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35"
2124
}
2225
}

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="tests/bootstrap.php"
1312
>
1413
<testsuites>

tests/React/Promise/DeferredTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@ public function shouldInvokeCancellationHandleWhenCancellingAllDerived()
204204

205205
/**
206206
* @test
207-
* @expectedException InvalidArgumentException
208207
*/
209208
public function shouldThrowIfCancellerIsNotACallable()
210209
{
210+
$this->setExpectedException('InvalidArgumentException');
211211
new Deferred(false);
212212
}
213213
}

tests/React/Promise/ErrorCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ public function assertCollectedError($errstr, $errno)
3333

3434
$message = 'Error with level ' . $errno . ' and message "' . $errstr . '" not found in ' . var_export($this->errors, true);
3535

36-
throw new \PHPUnit_Framework_AssertionFailedError($message);
36+
throw new \PHPUnit\Framework\AssertionFailedError($message);
3737
}
3838
}

tests/React/Promise/PromiseTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class PromiseTest extends TestCase
1010
/** @test */
1111
public function shouldThrowIfResolverIsNotACallable()
1212
{
13-
$this->setExpectedException('\InvalidArgumentException');
13+
$this->setExpectedException('InvalidArgumentException');
1414

1515
new Promise(null);
1616
}
@@ -93,10 +93,10 @@ public function shouldInvokeCancellationHandlerAndStayPendingWhenCallingCancel()
9393

9494
/**
9595
* @test
96-
* @expectedException InvalidArgumentException
9796
*/
9897
public function shouldThrowIfCancellerIsNotACallable()
9998
{
99+
$this->setExpectedException('InvalidArgumentException');
100100
new Promise(function () { }, false);
101101
}
102102
}

tests/React/Promise/Stub/CallableStub.php

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

tests/React/Promise/TestCase.php

Lines changed: 25 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,9 +36,13 @@ public function expectCallableNever()
3636

3737
public function createCallableMock()
3838
{
39-
return $this
40-
->getMockBuilder('React\\Promise\Stub\CallableStub')
41-
->getMock();
39+
if (method_exists('PHPUnit\Framework\MockObject\MockBuilder', 'addMethods')) {
40+
// PHPUnit 9+
41+
return $this->getMockBuilder('stdClass')->addMethods(array('__invoke'))->getMock();
42+
} else {
43+
// legacy PHPUnit 4 - PHPUnit 9
44+
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
45+
}
4246
}
4347

4448
public function invalidCallbackDataProvider()
@@ -52,4 +56,21 @@ public function invalidCallbackDataProvider()
5256
'falsey' => array(0)
5357
);
5458
}
59+
60+
public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null)
61+
{
62+
if (method_exists($this, 'expectException')) {
63+
// PHPUnit 5+
64+
$this->expectException($exception);
65+
if ($exceptionMessage !== '') {
66+
$this->expectExceptionMessage($exceptionMessage);
67+
}
68+
if ($exceptionCode !== null) {
69+
$this->expectExceptionCode($exceptionCode);
70+
}
71+
} else {
72+
// legacy PHPUnit 4
73+
parent::setExpectedException($exception, $exceptionMessage, $exceptionCode);
74+
}
75+
}
5576
}

0 commit comments

Comments
 (0)