Skip to content

Commit 0e984d7

Browse files
committed
Update PHPUnit configuration schema for PHPUnit 9.3 and minor clean up
1 parent ff5e01d commit 0e984d7

File tree

8 files changed

+35
-26
lines changed

8 files changed

+35
-26
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
/.travis.yml export-ignore
44
/examples export-ignore
55
/phpunit.xml.dist export-ignore
6+
/phpunit.xml.legacy export-ignore
67
/tests export-ignore

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ jobs:
2929
- os: osx
3030

3131
install:
32-
- composer install --no-interaction
32+
- composer install
3333

3434
script:
35-
- vendor/bin/phpunit --coverage-text
35+
- if [[ "$TRAVIS_PHP_VERSION" > "7.2" ]]; then vendor/bin/phpunit --coverage-text; fi
36+
- if [[ "$TRAVIS_PHP_VERSION" < "7.3" ]]; then vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy; fi
3637
- time php examples/91-benchmark-throughput.php

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"evenement/evenement": "^3.0 || ^2.0 || ^1.0"
3232
},
3333
"require-dev": {
34-
"phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35",
34+
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35",
3535
"clue/stream-filter": "~1.2"
3636
},
3737
"autoload": {

phpunit.xml.dist

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<phpunit bootstrap="vendor/autoload.php" colors="true">
3+
<!-- PHPUnit configuration file with new format for PHPUnit 9.3+ -->
4+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
6+
bootstrap="vendor/autoload.php"
7+
colors="true"
8+
cacheResult="false">
49
<testsuites>
510
<testsuite name="React Test Suite">
611
<directory>./tests/</directory>
712
</testsuite>
813
</testsuites>
9-
10-
<filter>
11-
<whitelist>
14+
<coverage>
15+
<include>
1216
<directory>./src/</directory>
13-
</whitelist>
14-
</filter>
17+
</include>
18+
</coverage>
1519
</phpunit>

phpunit.xml.legacy

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!-- PHPUnit configuration file with old format for PHPUnit 9.2 or older -->
4+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
6+
bootstrap="vendor/autoload.php"
7+
colors="true">
8+
<testsuites>
9+
<testsuite name="React Test Suite">
10+
<directory>./tests/</directory>
11+
</testsuite>
12+
</testsuites>
13+
<filter>
14+
<whitelist>
15+
<directory>./src/</directory>
16+
</whitelist>
17+
</filter>
18+
</phpunit>

tests/TestCase.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@
66

77
class TestCase extends BaseTestCase
88
{
9-
protected function expectCallableExactly($amount)
10-
{
11-
$mock = $this->createCallableMock();
12-
$mock
13-
->expects($this->exactly($amount))
14-
->method('__invoke');
15-
16-
return $mock;
17-
}
18-
199
protected function expectCallableOnce()
2010
{
2111
$mock = $this->createCallableMock();
@@ -61,7 +51,7 @@ protected function createCallableMock()
6151
public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null)
6252
{
6353
if (method_exists($this, 'expectException')) {
64-
// PHPUnit 5+
54+
// PHPUnit 5.2+
6555
$this->expectException($exception);
6656
if ($exceptionMessage !== '') {
6757
$this->expectExceptionMessage($exceptionMessage);
@@ -70,7 +60,7 @@ public function setExpectedException($exception, $exceptionMessage = '', $except
7060
$this->expectExceptionCode($exceptionCode);
7161
}
7262
} else {
73-
// legacy PHPUnit 4
63+
// legacy PHPUnit 4 - PHPUnit 5.1
7464
parent::setExpectedException($exception, $exceptionMessage, $exceptionCode);
7565
}
7666
}

tests/UtilTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,4 @@ private function createLoopMock()
265265
{
266266
return $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
267267
}
268-
269-
private function notEqualTo($value)
270-
{
271-
return new \PHPUnit_Framework_Constraint_Not($value);
272-
}
273268
}

0 commit comments

Comments
 (0)