Skip to content

Commit

Permalink
Merge pull request #212 from SimonFrings/tests
Browse files Browse the repository at this point in the history
Run tests on PHPUnit 9 and clean up test suite
  • Loading branch information
jsor committed Jul 19, 2020
2 parents 88aaa77 + 14e799d commit 363a76d
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 29 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: php
# lock distro so new future defaults will not break the build
dist: xenial

matrix:
jobs:
include:
- php: 5.3
dist: precise
Expand All @@ -24,7 +24,7 @@ matrix:
dist: trusty
before_install: [] # skip libuv
install:
- composer require phpunit/phpunit:^5 --dev --no-interaction # requires legacy phpunit & skip ./travis-init.sh
- composer install # skip ./travis-init.sh
- name: "Windows"
os: windows
language: shell # no built-in php support
Expand Down Expand Up @@ -66,8 +66,6 @@ matrix:
- php: hhvm-3.18
- os: windows

sudo: false

addons:
apt:
packages:
Expand Down
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
11 changes: 1 addition & 10 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="vendor/autoload.php"
>
<phpunit bootstrap="vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="React Test Suite">
<directory>./tests/</directory>
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 363a76d

Please sign in to comment.