Skip to content

Add PHPUnit to require-dev #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ install:
- composer install --no-interaction

script:
- phpunit --coverage-text
- vendor/bin/phpunit --coverage-text
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Async, event-driven and UTF-8 aware console input & output (STDIN, STDOUT), buil
* [Stdin](#stdin)
* [Pitfalls](#pitfalls)
* [Install](#install)
* [Tests](#tests)
* [License](#license)
* [More](#more)

Expand Down Expand Up @@ -554,6 +555,21 @@ $ composer require clue/stdio-react:^1.0

More details and upgrade guides can be found in the [CHANGELOG](CHANGELOG.md).

## 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
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"psr-4": { "Clue\\React\\Stdio\\": "src/" }
},
"require-dev": {
"phpunit/phpunit": "^5.0 || ^4.8",
"clue/commander": "^1.2",
"clue/arguments": "^2.0"
}
Expand Down
10 changes: 5 additions & 5 deletions tests/ReadlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ReadlineTest extends TestCase
public function setUp()
{
$this->input = new ReadableStream();
$this->output = $this->getMock('React\Stream\WritableStreamInterface');
$this->output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

$this->readline = new Readline($this->input, $this->output);
}
Expand Down Expand Up @@ -983,7 +983,7 @@ public function testEmitCloseWillEmitClose()

public function testClosedStdinWillCloseReadline()
{
$this->input = $this->getMock('React\Stream\ReadableStreamInterface');
$this->input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$this->input->expects($this->once())->method('isReadable')->willReturn(false);

$this->readline = new Readline($this->input, $this->output);
Expand All @@ -993,7 +993,7 @@ public function testClosedStdinWillCloseReadline()

public function testPauseWillBeForwarded()
{
$this->input = $this->getMock('React\Stream\ReadableStreamInterface');
$this->input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$this->input->expects($this->once())->method('pause');

$this->readline = new Readline($this->input, $this->output);
Expand All @@ -1003,7 +1003,7 @@ public function testPauseWillBeForwarded()

public function testResumeWillBeForwarded()
{
$this->input = $this->getMock('React\Stream\ReadableStreamInterface');
$this->input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$this->input->expects($this->once())->method('resume');

$this->readline = new Readline($this->input, $this->output);
Expand All @@ -1013,7 +1013,7 @@ public function testResumeWillBeForwarded()

public function testPipeWillReturnDest()
{
$dest = $this->getMock('React\Stream\WritableStreamInterface');
$dest = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

$ret = $this->readline->pipe($dest);

Expand Down
100 changes: 50 additions & 50 deletions tests/StdioTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public function testCtorDefaultArgs()

public function testCtorArgsWillBeReturnedByGetters()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -38,8 +38,8 @@ public function testCtorArgsWillBeReturnedByGetters()

public function testWriteEmptyStringWillNotWriteToOutput()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -55,8 +55,8 @@ public function testWriteEmptyStringWillNotWriteToOutput()

public function testWriteWillClearReadlineWriteOutputAndRestoreReadline()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -77,8 +77,8 @@ public function testWriteWillClearReadlineWriteOutputAndRestoreReadline()

public function testWriteAgainWillMoveToPreviousLineWriteOutputAndRestoreReadlinePosition()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -101,8 +101,8 @@ public function testWriteAgainWillMoveToPreviousLineWriteOutputAndRestoreReadlin

public function testWriteAgainWithBackspaceWillMoveToPreviousLineWriteOutputAndRestoreReadlinePosition()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -125,8 +125,8 @@ public function testWriteAgainWithBackspaceWillMoveToPreviousLineWriteOutputAndR

public function testWriteAgainWithNewlinesWillClearReadlineMoveToPreviousLineWriteOutputAndRestoreReadline()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -149,8 +149,8 @@ public function testWriteAgainWithNewlinesWillClearReadlineMoveToPreviousLineWri

public function testWriteAfterReadlineInputWillClearReadlineWriteOutputAndRestoreReadline()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -175,8 +175,8 @@ public function testWriteAfterReadlineInputWillClearReadlineWriteOutputAndRestor

public function testOverwriteWillClearReadlineMoveToPreviousLineWriteOutputAndRestoreReadline()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -199,8 +199,8 @@ public function testOverwriteWillClearReadlineMoveToPreviousLineWriteOutputAndRe

public function testOverwriteAfterNewlineWillClearReadlineAndWriteOutputAndRestoreReadline()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -223,8 +223,8 @@ public function testOverwriteAfterNewlineWillClearReadlineAndWriteOutputAndResto

public function testWriteLineWillClearReadlineWriteOutputAndRestoreReadline()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -245,8 +245,8 @@ public function testWriteLineWillClearReadlineWriteOutputAndRestoreReadline()

public function testWriteTwoLinesWillClearReadlineWriteOutputAndRestoreReadline()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -268,8 +268,8 @@ public function testWriteTwoLinesWillClearReadlineWriteOutputAndRestoreReadline(

public function testPauseWillBeForwardedToInput()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -283,8 +283,8 @@ public function testPauseWillBeForwardedToInput()

public function testResumeWillBeForwardedToInput()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -298,8 +298,8 @@ public function testResumeWillBeForwardedToInput()

public function testReadableWillBeForwardedToInput()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -313,15 +313,15 @@ public function testReadableWillBeForwardedToInput()

public function testPipeWillReturnDestStream()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);

$stdio = new Stdio($this->loop, $input, $output, $readline);

$dest = $this->getMock('React\Stream\WritableStreamInterface');
$dest = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

$ret = $stdio->pipe($dest);

Expand All @@ -330,8 +330,8 @@ public function testPipeWillReturnDestStream()

public function testWritableWillBeForwardedToOutput()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -345,8 +345,8 @@ public function testWritableWillBeForwardedToOutput()

public function testCloseWillCloseInputAndOutput()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -361,8 +361,8 @@ public function testCloseWillCloseInputAndOutput()

public function testCloseTwiceWillCloseInputAndOutputOnlyOnce()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -378,8 +378,8 @@ public function testCloseTwiceWillCloseInputAndOutputOnlyOnce()

public function testEndWillCloseInputAndEndOutput()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -394,8 +394,8 @@ public function testEndWillCloseInputAndEndOutput()

public function testEndWithDataWillWriteAndCloseInputAndEndOutput()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -412,8 +412,8 @@ public function testEndWithDataWillWriteAndCloseInputAndEndOutput()

public function testWriteAfterEndWillNotWriteToOutput()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -428,8 +428,8 @@ public function testWriteAfterEndWillNotWriteToOutput()

public function testEndTwiceWillCloseInputAndEndOutputOnce()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -445,8 +445,8 @@ public function testEndTwiceWillCloseInputAndEndOutputOnce()

public function testDataEventWillBeForwarded()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$output = $this->getMock('React\Stream\WritableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -462,7 +462,7 @@ public function testDataEventWillBeForwarded()
public function testEndEventWillBeForwarded()
{
$input = new ReadableStream();
$output = $this->getMock('React\Stream\WritableStreamInterface');
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -477,7 +477,7 @@ public function testEndEventWillBeForwarded()
public function testErrorEventFromInputWillBeForwarded()
{
$input = new ReadableStream();
$output = $this->getMock('React\Stream\WritableStreamInterface');
$output = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
$readline = new Readline($input, $output);
Expand All @@ -491,7 +491,7 @@ public function testErrorEventFromInputWillBeForwarded()

public function testErrorEventFromOutputWillBeForwarded()
{
$input = $this->getMock('React\Stream\ReadableStreamInterface');
$input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$output = new WritableStream();

//$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
Expand Down
Loading