diff --git a/.travis.yml b/.travis.yml index 3464291..6983d72 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,4 +14,4 @@ install: - composer install --no-interaction script: - - phpunit --coverage-text + - vendor/bin/phpunit --coverage-text diff --git a/README.md b/README.md index 5261d5a..effba9e 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ Streaming newline delimited JSON ([NDJSON](http://ndjson.org/)) parser and encod * [Decoder](#decoder) * [Encoder](#encoder) * [Install](#install) +* [Tests](#tests) * [License](#license) * [More](#more) @@ -197,6 +198,20 @@ $ composer require clue/ndjson-react:^0.1 See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades. +## Tests + +To run the test suite, you first need to clone this repo and then install all dependencies [through Composer](http://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 83e6118..f0eb6de 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,7 @@ "react/stream": "^0.4 || ^0.3" }, "require-dev": { - "react/event-loop": " ^0.4 || ^0.3" + "react/event-loop": " ^0.4 || ^0.3", + "phpunit/phpunit": "^5.0 || ^4.8" } } diff --git a/tests/DecoderTest.php b/tests/DecoderTest.php index 25de9c0..b62d933 100644 --- a/tests/DecoderTest.php +++ b/tests/DecoderTest.php @@ -180,7 +180,7 @@ public function testEmitErrorEventWillForwardAndClose() public function testPipeReturnsDestStream() { - $dest = $this->getMock('React\Stream\WritableStreamInterface'); + $dest = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock(); $ret = $this->decoder->pipe($dest); @@ -189,7 +189,7 @@ public function testPipeReturnsDestStream() public function testForwardPauseToInput() { - $this->input = $this->getMock('React\Stream\ReadableStreamInterface'); + $this->input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock(); $this->input->expects($this->once())->method('pause'); $this->decoder = new Decoder($this->input); @@ -198,7 +198,7 @@ public function testForwardPauseToInput() public function testForwardResumeToInput() { - $this->input = $this->getMock('React\Stream\ReadableStreamInterface'); + $this->input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock(); $this->input->expects($this->once())->method('resume'); $this->decoder = new Decoder($this->input); diff --git a/tests/EncoderTest.php b/tests/EncoderTest.php index 5b4486a..be1949b 100644 --- a/tests/EncoderTest.php +++ b/tests/EncoderTest.php @@ -28,7 +28,7 @@ public function testPrettyPrintDoesNotMakeSenseForNDJson() public function testWriteString() { - $this->output = $this->getMock('React\Stream\WritableStreamInterface'); + $this->output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock(); $this->output->expects($this->once())->method('isWritable')->willReturn(true); $this->encoder = new Encoder($this->output); @@ -39,7 +39,7 @@ public function testWriteString() public function testWriteNull() { - $this->output = $this->getMock('React\Stream\WritableStreamInterface'); + $this->output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock(); $this->output->expects($this->once())->method('isWritable')->willReturn(true); $this->encoder = new Encoder($this->output); @@ -50,7 +50,7 @@ public function testWriteNull() public function testWriteInfiniteWillEmitErrorAndClose() { - $this->output = $this->getMock('React\Stream\WritableStreamInterface'); + $this->output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock(); $this->output->expects($this->once())->method('isWritable')->willReturn(true); $this->encoder = new Encoder($this->output); @@ -66,7 +66,7 @@ public function testWriteInfiniteWillEmitErrorAndClose() public function testEndWithoutDataWillEndOutputWithoutData() { - $this->output = $this->getMock('React\Stream\WritableStreamInterface'); + $this->output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock(); $this->output->expects($this->once())->method('isWritable')->willReturn(true); $this->encoder = new Encoder($this->output); @@ -78,7 +78,7 @@ public function testEndWithoutDataWillEndOutputWithoutData() public function testEndWithDataWillForwardDataAndEndOutputWithoutData() { - $this->output = $this->getMock('React\Stream\WritableStreamInterface'); + $this->output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock(); $this->output->expects($this->once())->method('isWritable')->willReturn(true); $this->encoder = new Encoder($this->output); @@ -106,7 +106,7 @@ public function testClosingOutputClosesEncoder() public function testPassingClosedStreamToEncoderWillCloseImmediately() { - $this->output = $this->getMock('React\Stream\WritableStreamInterface'); + $this->output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock(); $this->output->expects($this->once())->method('isWritable')->willReturn(false); $this->encoder = new Encoder($this->output); @@ -115,7 +115,7 @@ public function testPassingClosedStreamToEncoderWillCloseImmediately() public function testWritingToClosedStreamWillNotForwardData() { - $this->output = $this->getMock('React\Stream\WritableStreamInterface'); + $this->output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock(); $this->output->expects($this->once())->method('isWritable')->willReturn(false); $this->encoder = new Encoder($this->output); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index d136462..91ad7d3 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -53,7 +53,7 @@ protected function expectCallableOnceParameter($type) */ protected function createCallableMock() { - return $this->getMock('CallableStub'); + return $this->getMockBuilder('CallableStub')->getMock(); } }