Skip to content

Commit 528d7c3

Browse files
authored
Merge pull request #24 from clue-labs/tests
Forward compatibility with PHP 7.1 and PHPUnit v5
2 parents b99f510 + 16fb979 commit 528d7c3

File tree

7 files changed

+20
-11
lines changed

7 files changed

+20
-11
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ php:
55
- 5.4
66
- 5.5
77
- 5.6
8-
- 7
8+
- 7.0
9+
- 7.1
910
- hhvm # ignore errors, see below
1011

1112
# lock distro so new future defaults will not break the build

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,17 @@ See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
151151

152152
## Tests
153153

154-
In order to run the tests, you need PHPUnit:
154+
To run the test suite, you first need to clone this repo and then install all
155+
dependencies [through Composer](http://getcomposer.org):
155156

156157
```bash
157-
$ phpunit
158+
$ composer install
159+
```
160+
161+
To run the test suite, go to the project root and run:
162+
163+
```bash
164+
$ php vendor/bin/phpunit
158165
```
159166

160167
The test suite contains both unit tests and functional integration tests.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
"php": ">=5.3",
1818
"react/event-loop": "~0.4.0|~0.3.0",
1919
"react/socket-client": "^0.5 || ^0.4 || ^0.3",
20-
"react/dns": "~0.4.0|~0.3.0",
20+
"react/dns": "^0.4.1 || ^0.3",
2121
"react/promise": "~2.0|~1.1",
2222
"react/stream": "^0.4.2",
2323
"clue/qdatastream": "^0.6"
2424
},
2525
"require-dev": {
2626
"clue/block-react": "^1.1",
27-
"phpunit/phpunit": "^4.8"
27+
"phpunit/phpunit": "^5.0 || ^4.8"
2828
}
2929
}

tests/ClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function setUp()
1818

1919
public function testCtorOptionalArgs()
2020
{
21-
$this->stream = $this->getMock('React\Stream\DuplexStreamInterface');
21+
$this->stream = $this->getMockBuilder('React\Stream\DuplexStreamInterface')->getMock();
2222
new Client($this->stream);
2323
}
2424

@@ -54,7 +54,7 @@ public function testPauseWillPauseUnderlyingStream()
5454

5555
public function testPipeWillReturnDestStream()
5656
{
57-
$dest = $this->getMock('React\Stream\WritableStreamInterface');
57+
$dest = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();
5858

5959
$this->assertEquals($dest, $this->client->pipe($dest));
6060
}

tests/FactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class FactoryTest extends TestCase
99
{
1010
public function setUp()
1111
{
12-
$this->loop = $this->getMock('React\EventLoop\LoopInterface');
13-
$this->connector = $this->getMock('React\SocketClient\ConnectorInterface');
12+
$this->loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
13+
$this->connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
1414
$this->prober = $this->getMockBuilder('Clue\React\Quassel\Io\Prober')->disableOriginalConstructor()->getMock();
1515

1616
$this->factory = new Factory($this->loop, $this->connector, $this->prober);

tests/FunctionalTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ public function testWriteClientLogin(Client $client, $message)
115115
*/
116116
public function testWriteHeartBeat(Client $client)
117117
{
118-
$time = new \DateTime();
118+
// explicitly write a fixed time (current date) in order to preserve milliseconds (for PHP 7.1+)
119+
$time = new \DateTime('10:20:30.456+00:00');
119120

120121
$promise = new Promise(function ($resolve) use ($client) {
121122
$callback = function ($message) use ($resolve, &$callback, $client) {

tests/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function expectCallableOnceParameter($type)
6363
*/
6464
protected function createCallableMock()
6565
{
66-
return $this->getMock('CallableStub');
66+
return $this->getMockBuilder('CallableStub')->getMock();
6767
}
6868

6969
protected function expectPromiseResolve($promise)

0 commit comments

Comments
 (0)