Skip to content
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/.travis.yml export-ignore
/examples export-ignore
/phpunit.xml.dist export-ignore
/phpunit.xml.legacy export-ignore
/tests export-ignore
33 changes: 14 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
language: php

php:
# - 5.3 # requires old distro, see below
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
# - hhvm # requires legacy phpunit & ignore errors, see below

# lock distro so new future defaults will not break the build
dist: trusty

matrix:
jobs:
include:
- php: 5.3
dist: precise
- php: hhvm
- php: 5.4
- php: 5.5
- php: 5.6
- php: 7.0
- php: 7.1
- php: 7.2
- php: 7.3
- php: 7.4
- php: hhvm-3.18
install: composer require phpunit/phpunit:^5 --dev --no-interaction
- name: "Windows"
os: windows
Expand All @@ -29,14 +25,13 @@ matrix:
- choco install composer
- export PATH="$(powershell -Command '("Process", "Machine" | % { [Environment]::GetEnvironmentVariable("PATH", $_) -Split ";" -Replace "\\$", "" } | Select -Unique | % { cygpath $_ }) -Join ":"')"
allow_failures:
- php: hhvm
- php: hhvm-3.18
- os: windows

sudo: false

install:
- composer install --no-interaction
- composer install

script:
- vendor/bin/phpunit --coverage-text
- if [[ "$TRAVIS_PHP_VERSION" > "7.2" ]]; then vendor/bin/phpunit --coverage-text; fi
- if [[ "$TRAVIS_PHP_VERSION" < "7.3" ]]; then vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy; fi
- php examples/13-benchmark-throughput.php
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"react/stream": "^1.0 || ^0.7.6"
},
"require-dev": {
"phpunit/phpunit": "^7.0 || ^6.4 || ^5.7 || ^4.8.35",
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35",
"react/socket": "^1.0",
"sebastian/environment": "^3.0 || ^2.0 || ^1.0"
"sebastian/environment": "^5.0 || ^3.0 || ^2.0 || ^1.0"
},
"autoload": {
"psr-4": { "React\\ChildProcess\\": "src" }
Expand Down
23 changes: 9 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
<!-- PHPUnit configuration file with new format for PHPUnit 9.3+ -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
>
colors="true"
cacheResult="false">
<testsuites>
<testsuite name="React Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<coverage>
<include>
<directory>./src/</directory>
</whitelist>
</filter>
</include>
</coverage>
</phpunit>
23 changes: 23 additions & 0 deletions phpunit.xml.legacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- PHPUnit configuration file with old format for PHPUnit 9.2 or older -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="React Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src/</directory>
</whitelist>
</filter>
</phpunit>
41 changes: 33 additions & 8 deletions tests/AbstractProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,15 @@ public function testStartWithCustomPipesWillAssignPipes()
$this->assertInstanceOf('React\Stream\WritableStreamInterface', $process->pipes[3]);
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage No such file or directory
*/
public function testStartWithInvalidFileDescriptorPathWillThrow()
{
$fds = array(
4 => array('file', '/dev/does-not-exist', 'r')
);

$process = new Process('exit 0', null, null, $fds);

$this->setExpectedException('RuntimeException', 'No such file or directory');
$process->start($this->createLoop());
}

Expand Down Expand Up @@ -130,7 +128,7 @@ public function testStartWithExcessiveNumberOfFileDescriptorsWillThrow()
// clear dummy files handles to make some room again (avoid fatal errors for autoloader)
$fds = array();

$this->assertContains('Too many open files', $e->getMessage());
$this->assertContainsString('Too many open files', $e->getMessage());
}
}

Expand Down Expand Up @@ -631,9 +629,6 @@ public function testStartInvalidProcess()
$this->assertNotEmpty($output);
}

/**
* @expectedException RuntimeException
*/
public function testStartAlreadyRunningProcess()
{
if (DIRECTORY_SEPARATOR === '\\') {
Expand All @@ -645,6 +640,8 @@ public function testStartAlreadyRunningProcess()
//var_dump($process);

$process->start($this->createLoop());

$this->setExpectedException('RuntimeException');
$process->start($this->createLoop());
}

Expand Down Expand Up @@ -873,4 +870,32 @@ private function getPhpBinary()

return $runtime->getBinary();
}

public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null)
{
if (method_exists($this, 'expectException')) {
// PHPUnit 5.2+
$this->expectException($exception);
if ($exceptionMessage !== '') {
$this->expectExceptionMessage($exceptionMessage);
}
if ($exceptionCode !== null) {
$this->expectExceptionCode($exceptionCode);
}
} else {
// legacy PHPUnit 4 - PHPUnit 5.1
parent::setExpectedException($exception, $exceptionMessage, $exceptionCode);
}
}

public function assertContainsString($needle, $haystack)
{
if (method_exists($this, 'assertStringContainsString')) {
// PHPUnit 7.5+
$this->assertStringContainsString($needle, $haystack);
} else {
// legacy PHPUnit 4 - PHPUnit 7.5
$this->assertContains($needle, $haystack);
}
}
}