Skip to content

Commit f07f22e

Browse files
authored
Merge pull request #5 from thklein/tests
Add PHPUnit to require-dev
2 parents e94f087 + 8ed21e6 commit f07f22e

File tree

6 files changed

+29
-13
lines changed

6 files changed

+29
-13
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ install:
1414
- composer install --no-interaction
1515

1616
script:
17-
- phpunit --coverage-text
17+
- vendor/bin/phpunit --coverage-text

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Streaming newline delimited JSON ([NDJSON](http://ndjson.org/)) parser and encod
88
* [Decoder](#decoder)
99
* [Encoder](#encoder)
1010
* [Install](#install)
11+
* [Tests](#tests)
1112
* [License](#license)
1213
* [More](#more)
1314

@@ -197,6 +198,20 @@ $ composer require clue/ndjson-react:^0.1
197198

198199
See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
199200

201+
## Tests
202+
203+
To run the test suite, you first need to clone this repo and then install all dependencies [through Composer](http://getcomposer.org):
204+
205+
```bash
206+
$ composer install
207+
```
208+
209+
To run the test suite, go to the project root and run:
210+
211+
```bash
212+
$ php vendor/bin/phpunit
213+
```
214+
200215
## License
201216

202217
MIT

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"react/stream": "^0.4 || ^0.3"
1919
},
2020
"require-dev": {
21-
"react/event-loop": " ^0.4 || ^0.3"
21+
"react/event-loop": " ^0.4 || ^0.3",
22+
"phpunit/phpunit": "^5.0 || ^4.8"
2223
}
2324
}

tests/DecoderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public function testEmitErrorEventWillForwardAndClose()
180180

181181
public function testPipeReturnsDestStream()
182182
{
183-
$dest = $this->getMock('React\Stream\WritableStreamInterface');
183+
$dest = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();
184184

185185
$ret = $this->decoder->pipe($dest);
186186

@@ -189,7 +189,7 @@ public function testPipeReturnsDestStream()
189189

190190
public function testForwardPauseToInput()
191191
{
192-
$this->input = $this->getMock('React\Stream\ReadableStreamInterface');
192+
$this->input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
193193
$this->input->expects($this->once())->method('pause');
194194

195195
$this->decoder = new Decoder($this->input);
@@ -198,7 +198,7 @@ public function testForwardPauseToInput()
198198

199199
public function testForwardResumeToInput()
200200
{
201-
$this->input = $this->getMock('React\Stream\ReadableStreamInterface');
201+
$this->input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
202202
$this->input->expects($this->once())->method('resume');
203203

204204
$this->decoder = new Decoder($this->input);

tests/EncoderTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testPrettyPrintDoesNotMakeSenseForNDJson()
2828

2929
public function testWriteString()
3030
{
31-
$this->output = $this->getMock('React\Stream\WritableStreamInterface');
31+
$this->output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();
3232
$this->output->expects($this->once())->method('isWritable')->willReturn(true);
3333
$this->encoder = new Encoder($this->output);
3434

@@ -39,7 +39,7 @@ public function testWriteString()
3939

4040
public function testWriteNull()
4141
{
42-
$this->output = $this->getMock('React\Stream\WritableStreamInterface');
42+
$this->output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();
4343
$this->output->expects($this->once())->method('isWritable')->willReturn(true);
4444
$this->encoder = new Encoder($this->output);
4545

@@ -50,7 +50,7 @@ public function testWriteNull()
5050

5151
public function testWriteInfiniteWillEmitErrorAndClose()
5252
{
53-
$this->output = $this->getMock('React\Stream\WritableStreamInterface');
53+
$this->output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();
5454
$this->output->expects($this->once())->method('isWritable')->willReturn(true);
5555
$this->encoder = new Encoder($this->output);
5656

@@ -66,7 +66,7 @@ public function testWriteInfiniteWillEmitErrorAndClose()
6666

6767
public function testEndWithoutDataWillEndOutputWithoutData()
6868
{
69-
$this->output = $this->getMock('React\Stream\WritableStreamInterface');
69+
$this->output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();
7070
$this->output->expects($this->once())->method('isWritable')->willReturn(true);
7171
$this->encoder = new Encoder($this->output);
7272

@@ -78,7 +78,7 @@ public function testEndWithoutDataWillEndOutputWithoutData()
7878

7979
public function testEndWithDataWillForwardDataAndEndOutputWithoutData()
8080
{
81-
$this->output = $this->getMock('React\Stream\WritableStreamInterface');
81+
$this->output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();
8282
$this->output->expects($this->once())->method('isWritable')->willReturn(true);
8383
$this->encoder = new Encoder($this->output);
8484

@@ -106,7 +106,7 @@ public function testClosingOutputClosesEncoder()
106106

107107
public function testPassingClosedStreamToEncoderWillCloseImmediately()
108108
{
109-
$this->output = $this->getMock('React\Stream\WritableStreamInterface');
109+
$this->output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();
110110
$this->output->expects($this->once())->method('isWritable')->willReturn(false);
111111
$this->encoder = new Encoder($this->output);
112112

@@ -115,7 +115,7 @@ public function testPassingClosedStreamToEncoderWillCloseImmediately()
115115

116116
public function testWritingToClosedStreamWillNotForwardData()
117117
{
118-
$this->output = $this->getMock('React\Stream\WritableStreamInterface');
118+
$this->output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();
119119
$this->output->expects($this->once())->method('isWritable')->willReturn(false);
120120
$this->encoder = new Encoder($this->output);
121121

tests/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected function expectCallableOnceParameter($type)
5353
*/
5454
protected function createCallableMock()
5555
{
56-
return $this->getMock('CallableStub');
56+
return $this->getMockBuilder('CallableStub')->getMock();
5757
}
5858
}
5959

0 commit comments

Comments
 (0)