From c96603be91dc024cdbb909edb3e823d760607205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Fri, 4 Aug 2017 18:04:11 +0200 Subject: [PATCH 1/2] Forward compatibility with PHPUnit v5 --- README.md | 11 +++++++++-- composer.json | 2 +- tests/ClientTest.php | 4 ++-- tests/FactoryTest.php | 4 ++-- tests/bootstrap.php | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a7297ca..7b115c5 100644 --- a/README.md +++ b/README.md @@ -151,10 +151,17 @@ See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades. ## Tests -In order to run the tests, you need PHPUnit: +To run the test suite, you first need to clone this repo and then install all +dependencies [through Composer](http://getcomposer.org): ```bash -$ phpunit +$ composer install +``` + +To run the test suite, go to the project root and run: + +```bash +$ php vendor/bin/phpunit ``` The test suite contains both unit tests and functional integration tests. diff --git a/composer.json b/composer.json index e96474e..00f8f72 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,6 @@ }, "require-dev": { "clue/block-react": "^1.1", - "phpunit/phpunit": "^4.8" + "phpunit/phpunit": "^5.0 || ^4.8" } } diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 37e18c4..7d507a1 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -18,7 +18,7 @@ public function setUp() public function testCtorOptionalArgs() { - $this->stream = $this->getMock('React\Stream\DuplexStreamInterface'); + $this->stream = $this->getMockBuilder('React\Stream\DuplexStreamInterface')->getMock(); new Client($this->stream); } @@ -54,7 +54,7 @@ public function testPauseWillPauseUnderlyingStream() public function testPipeWillReturnDestStream() { - $dest = $this->getMock('React\Stream\WritableStreamInterface'); + $dest = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock(); $this->assertEquals($dest, $this->client->pipe($dest)); } diff --git a/tests/FactoryTest.php b/tests/FactoryTest.php index 59bf89e..ff6caa5 100644 --- a/tests/FactoryTest.php +++ b/tests/FactoryTest.php @@ -9,8 +9,8 @@ class FactoryTest extends TestCase { public function setUp() { - $this->loop = $this->getMock('React\EventLoop\LoopInterface'); - $this->connector = $this->getMock('React\SocketClient\ConnectorInterface'); + $this->loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); + $this->connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock(); $this->prober = $this->getMockBuilder('Clue\React\Quassel\Io\Prober')->disableOriginalConstructor()->getMock(); $this->factory = new Factory($this->loop, $this->connector, $this->prober); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 32d9f07..35e781a 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -63,7 +63,7 @@ protected function expectCallableOnceParameter($type) */ protected function createCallableMock() { - return $this->getMock('CallableStub'); + return $this->getMockBuilder('CallableStub')->getMock(); } protected function expectPromiseResolve($promise) From 16fb979ff6d37db214f033f9fe23bb30b6e091ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Fri, 4 Aug 2017 18:10:29 +0200 Subject: [PATCH 2/2] Test against PHP 7.1 and lowest dependencies --- .travis.yml | 3 ++- composer.json | 2 +- tests/FunctionalTest.php | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 01876ef..3ace5ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,8 @@ php: - 5.4 - 5.5 - 5.6 - - 7 + - 7.0 + - 7.1 - hhvm # ignore errors, see below # lock distro so new future defaults will not break the build diff --git a/composer.json b/composer.json index 00f8f72..1e41c1b 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "php": ">=5.3", "react/event-loop": "~0.4.0|~0.3.0", "react/socket-client": "^0.5 || ^0.4 || ^0.3", - "react/dns": "~0.4.0|~0.3.0", + "react/dns": "^0.4.1 || ^0.3", "react/promise": "~2.0|~1.1", "react/stream": "^0.4.2", "clue/qdatastream": "^0.6" diff --git a/tests/FunctionalTest.php b/tests/FunctionalTest.php index d7f61ef..b75edca 100644 --- a/tests/FunctionalTest.php +++ b/tests/FunctionalTest.php @@ -115,7 +115,8 @@ public function testWriteClientLogin(Client $client, $message) */ public function testWriteHeartBeat(Client $client) { - $time = new \DateTime(); + // explicitly write a fixed time (current date) in order to preserve milliseconds (for PHP 7.1+) + $time = new \DateTime('10:20:30.456+00:00'); $promise = new Promise(function ($resolve) use ($client) { $callback = function ($message) use ($resolve, &$callback, $client) {