From bbd71563984c90de13d87f43056ef494c13438cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Thu, 5 Sep 2019 15:58:29 +0200 Subject: [PATCH 1/3] Add tests instructions and add PHPUnit to require-dev --- .travis.yml | 7 ++++-- README.md | 16 ++++++++++++++ composer.json | 3 ++- tests/bootstrap.php | 53 +-------------------------------------------- 4 files changed, 24 insertions(+), 55 deletions(-) diff --git a/.travis.yml b/.travis.yml index d6e1dfe..a1aaa53 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,12 @@ language: php + php: - 5.3 - 5.6 - hhvm + install: - - composer install --prefer-source --no-interaction + - composer install --no-interaction + script: - - phpunit --coverage-text + - vendor/bin/phpunit --coverage-text diff --git a/README.md b/README.md index 4d8c87b..917310a 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Implements UStar (Uniform Standard Tape ARchive) format, introduced by the POSIX * [Quickstart example](#quickstart-example) * [Install](#install) +* [Tests](#tests) * [License](#license) * [More](#more) @@ -54,6 +55,21 @@ The recommended way to install this library is [through composer](https://getcom } ``` +## Tests + +To run the test suite, you first need to clone this repo and then install all +dependencies [through Composer](https://getcomposer.org): + +```bash +$ composer install +``` + +To run the test suite, go to the project root and run: + +```bash +$ php vendor/bin/phpunit +``` + ## License MIT diff --git a/composer.json b/composer.json index b0ce38e..f5360c4 100644 --- a/composer.json +++ b/composer.json @@ -15,9 +15,10 @@ "react/stream": "~0.4.0|~0.3.0" }, "require-dev": { + "clue/hexdump": "~0.2.0", "react/event-loop": "~0.4.0|~0.3.0", "react/promise": "~2.0|~1.0", - "clue/hexdump": "~0.2.0" + "phpunit/phpunit": "^4.8.35" }, "autoload": { "psr-4": { "Clue\\React\\Tar\\": "src/" } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 4f81975..3afc582 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -26,59 +26,8 @@ protected function expectCallableNever() return $mock; } - protected function expectCallableOnceWith($value) - { - $mock = $this->createCallableMock(); - $mock - ->expects($this->once()) - ->method('__invoke') - ->with($this->equalTo($value)); - - return $mock; - } - - protected function expectCallableOnceParameter($type) - { - $mock = $this->createCallableMock(); - $mock - ->expects($this->once()) - ->method('__invoke') - ->with($this->isInstanceOf($type)); - - return $mock; - } - - /** - * @link https://github.com/reactphp/react/blob/master/tests/React/Tests/Socket/TestCase.php (taken from reactphp/react) - */ protected function createCallableMock() { - return $this->getMock('CallableStub'); - } - - protected function expectPromiseResolve($promise) - { - $this->assertInstanceOf('React\Promise\PromiseInterface', $promise); - - $promise->then($this->expectCallableOnce(), $this->expectCallableNever()); - - return $promise; - } - - protected function expectPromiseReject($promise) - { - $this->assertInstanceOf('React\Promise\PromiseInterface', $promise); - - $promise->then($this->expectCallableNever(), $this->expectCallableOnce()); - - return $promise; - } -} - -class CallableStub -{ - public function __invoke() - { + return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock(); } } - From b840c255d0362f70fcb745c307ecd4126026d711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Thu, 5 Sep 2019 16:29:03 +0200 Subject: [PATCH 2/3] Update to support PHPUnit 7, PHPUnit 6 and PHPUnit 5 --- composer.json | 5 ++++- phpunit.xml.dist | 2 +- tests/DecoderTest.php | 5 +++++ tests/FunctionalDecoderTest.php | 8 ++++++++ tests/{bootstrap.php => TestCase.php} | 6 ++---- 5 files changed, 20 insertions(+), 6 deletions(-) rename tests/{bootstrap.php => TestCase.php} (82%) diff --git a/composer.json b/composer.json index f5360c4..29108ed 100644 --- a/composer.json +++ b/composer.json @@ -18,9 +18,12 @@ "clue/hexdump": "~0.2.0", "react/event-loop": "~0.4.0|~0.3.0", "react/promise": "~2.0|~1.0", - "phpunit/phpunit": "^4.8.35" + "phpunit/phpunit": "^7.0 || ^6.0 || ^5.0 || ^4.8.35" }, "autoload": { "psr-4": { "Clue\\React\\Tar\\": "src/" } + }, + "autoload-dev": { + "psr-4": { "Clue\\Tests\\React\\Tar\\": "tests/" } } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4750166..82061b0 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,6 @@ -decoder->write(str_repeat('2', 1024)); } + /** + * @doesNotPerformAssertions + */ public function testWritingToClosedDecoderDoesNothing() { $this->decoder->close(); diff --git a/tests/FunctionalDecoderTest.php b/tests/FunctionalDecoderTest.php index 0b67603..fbde4b1 100644 --- a/tests/FunctionalDecoderTest.php +++ b/tests/FunctionalDecoderTest.php @@ -1,5 +1,7 @@ loop = new StreamSelectLoop(); } + /** + * @doesNotPerformAssertions + */ public function testAliceBob() { $stream = $this->createStream('alice-bob.tar'); @@ -23,6 +28,9 @@ public function testAliceBob() $this->loop->run(); } + /** + * @doesNotPerformAssertions + */ public function testAliceBobWithSmallBufferSize() { $stream = $this->createStream('alice-bob.tar'); diff --git a/tests/bootstrap.php b/tests/TestCase.php similarity index 82% rename from tests/bootstrap.php rename to tests/TestCase.php index 3afc582..82b3cc6 100644 --- a/tests/bootstrap.php +++ b/tests/TestCase.php @@ -1,10 +1,8 @@ Date: Thu, 5 Sep 2019 16:29:44 +0200 Subject: [PATCH 3/3] Test against legacy PHP 5.3 through PHP 7.3 --- .travis.yml | 17 +++++++++++++++-- README.md | 4 ++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a1aaa53..a8ed5b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,22 @@ language: php php: - - 5.3 +# - 5.3 # requires old distro, see below + - 5.4 + - 5.5 - 5.6 - - hhvm + - 7.0 + - 7.1 + - 7.2 + - 7.3 + +# lock distro so future defaults will not break the build +dist: trusty + +matrix: + include: + - php: 5.3 + dist: precise install: - composer install --no-interaction diff --git a/README.md b/README.md index 917310a..8dafd30 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,10 @@ The recommended way to install this library is [through composer](https://getcom } ``` +This project aims to run on any platform and thus does not require any PHP +extensions and supports running on legacy PHP 5.3 through current PHP 7+. +It's *highly recommended to use PHP 7+* for this project. + ## Tests To run the test suite, you first need to clone this repo and then install all