diff --git a/.gitattributes b/.gitattributes index f2f51dd..64ab6e0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,4 +3,5 @@ /.travis.yml export-ignore /examples export-ignore /phpunit.xml.dist export-ignore +/phpunit.xml.legacy export-ignore /tests export-ignore diff --git a/.travis.yml b/.travis.yml index cc82aaf..a2498b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,8 +29,9 @@ jobs: - os: osx 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 - time php examples/91-benchmark-throughput.php diff --git a/composer.json b/composer.json index d376084..aada0be 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "evenement/evenement": "^3.0 || ^2.0 || ^1.0" }, "require-dev": { - "phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35", + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35", "clue/stream-filter": "~1.2" }, "autoload": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0e947b8..fa88e7e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,15 +1,19 @@ - + + ./tests/ - - - + + ./src/ - - + + diff --git a/phpunit.xml.legacy b/phpunit.xml.legacy new file mode 100644 index 0000000..fbb43e8 --- /dev/null +++ b/phpunit.xml.legacy @@ -0,0 +1,18 @@ + + + + + + + ./tests/ + + + + + ./src/ + + + diff --git a/tests/TestCase.php b/tests/TestCase.php index 2b0928f..7bef2f5 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -6,16 +6,6 @@ class TestCase extends BaseTestCase { - protected function expectCallableExactly($amount) - { - $mock = $this->createCallableMock(); - $mock - ->expects($this->exactly($amount)) - ->method('__invoke'); - - return $mock; - } - protected function expectCallableOnce() { $mock = $this->createCallableMock(); @@ -61,7 +51,7 @@ protected function createCallableMock() public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null) { if (method_exists($this, 'expectException')) { - // PHPUnit 5+ + // PHPUnit 5.2+ $this->expectException($exception); if ($exceptionMessage !== '') { $this->expectExceptionMessage($exceptionMessage); @@ -70,7 +60,7 @@ public function setExpectedException($exception, $exceptionMessage = '', $except $this->expectExceptionCode($exceptionCode); } } else { - // legacy PHPUnit 4 + // legacy PHPUnit 4 - PHPUnit 5.1 parent::setExpectedException($exception, $exceptionMessage, $exceptionCode); } } diff --git a/tests/UtilTest.php b/tests/UtilTest.php index 3d113ab..f12baad 100644 --- a/tests/UtilTest.php +++ b/tests/UtilTest.php @@ -265,9 +265,4 @@ private function createLoopMock() { return $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); } - - private function notEqualTo($value) - { - return new \PHPUnit_Framework_Constraint_Not($value); - } } diff --git a/tests/WritableStreamResourceTest.php b/tests/WritableResourceStreamTest.php similarity index 94% rename from tests/WritableStreamResourceTest.php rename to tests/WritableResourceStreamTest.php index 3192abd..7b36418 100644 --- a/tests/WritableStreamResourceTest.php +++ b/tests/WritableResourceStreamTest.php @@ -461,33 +461,6 @@ public function testWritingToClosedWritableResourceStreamShouldNotWriteToStream( $this->assertSame('', $filterBuffer); } - /** - * @covers React\Stream\WritableResourceStream::handleWrite - */ - public function testErrorWhenStreamResourceIsInvalid() - { - $stream = fopen('php://temp', 'r+'); - $loop = $this->createWriteableLoopMock(); - - $error = null; - - $buffer = new WritableResourceStream($stream, $loop); - $buffer->on('error', function ($message) use (&$error) { - $error = $message; - }); - - // invalidate stream resource - fclose($stream); - - $buffer->write('Attempting to write to bad stream'); - - $this->assertInstanceOf('Exception', $error); - - // the error messages differ between PHP versions, let's just check substrings - $this->assertContainsString('Unable to write to stream: ', $error->getMessage()); - $this->assertContainsStringIgnoringCase(' Not a valid stream resource', $error->getMessage()); - } - public function testWritingToClosedStream() { if ('Darwin' === PHP_OS) {