Skip to content

Commit

Permalink
Run tests on PHPUnit 9
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonFrings committed Jul 17, 2020
1 parent 88aaa77 commit 02c6c53
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "^7.0 || ^6.4 || ^5.7 || ^4.8.35"
"phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35"
},
"suggest": {
"ext-event": "~1.0 for ExtEventLoop",
Expand Down
9 changes: 8 additions & 1 deletion tests/AbstractLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ abstract class AbstractLoopTest extends TestCase

const PHP_DEFAULT_CHUNK_SIZE = 8192;

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

public function testAddWriteStreamTriggersWhenSocketConnectionRefused()
{
if (defined('HHVM_VERSION')) {
$this->markTestSkipped('Not supported on HHVM');
}

// first verify the operating system actually refuses the connection and no firewall is in place
// use higher timeout because Windows retires multiple times and has a noticeable delay
// @link https://stackoverflow.com/questions/19440364/why-do-failed-attempts-of-socket-connect-take-1-sec-on-windows
Expand Down
10 changes: 0 additions & 10 deletions tests/CallableStub.php

This file was deleted.

5 changes: 4 additions & 1 deletion tests/ExtLibeventLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public function createLoop()
return new ExtLibeventLoop();
}

public function tearDown()
/**
* @after
*/
public function tearDownFile()
{
if (file_exists($this->fifoPath)) {
unlink($this->fifoPath);
Expand Down
5 changes: 4 additions & 1 deletion tests/StreamSelectLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

class StreamSelectLoopTest extends AbstractLoopTest
{
protected function tearDown()
/**
* @after
*/
protected function tearDownSignalHandlers()
{
parent::tearDown();
if (strncmp($this->getName(false), 'testSignal', 10) === 0 && extension_loaded('pcntl')) {
Expand Down
8 changes: 7 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ protected function expectCallableNever()

protected function createCallableMock()
{
return $this->getMockBuilder('React\Tests\EventLoop\CallableStub')->getMock();
if (method_exists('PHPUnit\Framework\MockObject\MockBuilder', 'addMethods')) {
// PHPUnit 9+
return $this->getMockBuilder('stdClass')->addMethods(array('__invoke'))->getMock();
} else {
// legacy PHPUnit 4 - PHPUnit 9
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
}
}

protected function tickLoop(LoopInterface $loop)
Expand Down

0 comments on commit 02c6c53

Please sign in to comment.