Skip to content

Commit 345ba45

Browse files
committed
Run tests on PHPUnit 9
1 parent 88aaa77 commit 345ba45

6 files changed

+25
-15
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
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",

tests/AbstractLoopTest.php

Lines changed: 9 additions & 1 deletion
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;
@@ -109,8 +112,13 @@ public function testAddWriteStreamTriggersWhenSocketConnectionSucceeds()
109112
$this->assertEquals(1, $called);
110113
}
111114

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

tests/CallableStub.php

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

tests/ExtLibeventLoopTest.php

Lines changed: 4 additions & 1 deletion
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

Lines changed: 4 additions & 1 deletion
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

Lines changed: 7 additions & 1 deletion
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)