Skip to content

Commit

Permalink
Merge pull request #24 from clue-labs/tests
Browse files Browse the repository at this point in the history
Forward compatibility with PHP 7.1 and PHPUnit v5
  • Loading branch information
clue authored Aug 4, 2017
2 parents b99f510 + 16fb979 commit 528d7c3
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
"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"
},
"require-dev": {
"clue/block-react": "^1.1",
"phpunit/phpunit": "^4.8"
"phpunit/phpunit": "^5.0 || ^4.8"
}
}
4 changes: 2 additions & 2 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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));
}
Expand Down
4 changes: 2 additions & 2 deletions tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function expectCallableOnceParameter($type)
*/
protected function createCallableMock()
{
return $this->getMock('CallableStub');
return $this->getMockBuilder('CallableStub')->getMock();
}

protected function expectPromiseResolve($promise)
Expand Down

0 comments on commit 528d7c3

Please sign in to comment.