Skip to content

Commit 363a76d

Browse files
authored
Merge pull request #212 from SimonFrings/tests
Run tests on PHPUnit 9 and clean up test suite
2 parents 88aaa77 + 14e799d commit 363a76d

8 files changed

+27
-29
lines changed

.travis.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ language: php
33
# lock distro so new future defaults will not break the build
44
dist: xenial
55

6-
matrix:
6+
jobs:
77
include:
88
- php: 5.3
99
dist: precise
@@ -24,7 +24,7 @@ matrix:
2424
dist: trusty
2525
before_install: [] # skip libuv
2626
install:
27-
- composer require phpunit/phpunit:^5 --dev --no-interaction # requires legacy phpunit & skip ./travis-init.sh
27+
- composer install # skip ./travis-init.sh
2828
- name: "Windows"
2929
os: windows
3030
language: shell # no built-in php support
@@ -66,8 +66,6 @@ matrix:
6666
- php: hhvm-3.18
6767
- os: windows
6868

69-
sudo: false
70-
7169
addons:
7270
apt:
7371
packages:

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"php": ">=5.3.0"
88
},
99
"require-dev": {
10-
"phpunit/phpunit": "^7.0 || ^6.4 || ^5.7 || ^4.8.35"
10+
"phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35"
1111
},
1212
"suggest": {
1313
"ext-event": "~1.0 for ExtEventLoop",

phpunit.xml.dist

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<phpunit backupGlobals="false"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
11-
bootstrap="vendor/autoload.php"
12-
>
3+
<phpunit bootstrap="vendor/autoload.php" colors="true">
134
<testsuites>
145
<testsuite name="React Test Suite">
156
<directory>./tests/</directory>

tests/AbstractLoopTest.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ abstract class AbstractLoopTest extends TestCase
1616

1717
const PHP_DEFAULT_CHUNK_SIZE = 8192;
1818

19-
public function setUp()
19+
/**
20+
* @before
21+
*/
22+
public function setUpLoop()
2023
{
2124
// It's a timeout, don't set it too low. Travis and other CI systems are slow.
2225
$this->tickTimeout = 0.02;
@@ -111,6 +114,10 @@ public function testAddWriteStreamTriggersWhenSocketConnectionSucceeds()
111114

112115
public function testAddWriteStreamTriggersWhenSocketConnectionRefused()
113116
{
117+
if (defined('HHVM_VERSION')) {
118+
$this->markTestSkipped('Not supported on HHVM');
119+
}
120+
114121
// first verify the operating system actually refuses the connection and no firewall is in place
115122
// use higher timeout because Windows retires multiple times and has a noticeable delay
116123
// @link https://stackoverflow.com/questions/19440364/why-do-failed-attempts-of-socket-connect-take-1-sec-on-windows

tests/CallableStub.php

-10
This file was deleted.

tests/ExtLibeventLoopTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ public function createLoop()
2121
return new ExtLibeventLoop();
2222
}
2323

24-
public function tearDown()
24+
/**
25+
* @after
26+
*/
27+
public function tearDownFile()
2528
{
2629
if (file_exists($this->fifoPath)) {
2730
unlink($this->fifoPath);

tests/StreamSelectLoopTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
class StreamSelectLoopTest extends AbstractLoopTest
99
{
10-
protected function tearDown()
10+
/**
11+
* @after
12+
*/
13+
protected function tearDownSignalHandlers()
1114
{
1215
parent::tearDown();
1316
if (strncmp($this->getName(false), 'testSignal', 10) === 0 && extension_loaded('pcntl')) {

tests/TestCase.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ protected function expectCallableNever()
3939

4040
protected function createCallableMock()
4141
{
42-
return $this->getMockBuilder('React\Tests\EventLoop\CallableStub')->getMock();
42+
if (method_exists('PHPUnit\Framework\MockObject\MockBuilder', 'addMethods')) {
43+
// PHPUnit 9+
44+
return $this->getMockBuilder('stdClass')->addMethods(array('__invoke'))->getMock();
45+
} else {
46+
// legacy PHPUnit 4 - PHPUnit 9
47+
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
48+
}
4349
}
4450

4551
protected function tickLoop(LoopInterface $loop)

0 commit comments

Comments
 (0)