Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests on PHPUnit 9 and clean up test suite #212

Merged
merged 2 commits into from
Jul 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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