Skip to content
Closed
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
16 changes: 14 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
language: php

php:
- 5.3
- 5.6
- 7.0
- 7.1
- 7.2
- hhvm

# also test against HHVM, but require "trusty" and ignore errors
matrix:
include:
- php: hhvm
dist: trusty
allow_failures:
- php: hhvm

install:
- composer install --prefer-source --no-interaction
script:
- phpunit --coverage-text
- vendor/bin/phpunit --coverage-text
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@
"psr-4" : { "Clue\\React\\Shell\\": "src/" }
},
"require": {
"php": ">=5.3",
"php": ">=5.6",
"react/promise": "~1.0|~2.0",
"react/child-process": "~0.3.0|~0.4.0",
"react/stream": "~0.3.0|~0.4.0",
"react/event-loop": "~0.3.0|~0.4.0"
"react/child-process": "~0.3.0|~0.4.0|^0.5",
"react/stream": "~0.3.0|~0.4.0|^0.5|^0.6|^0.7",
"react/event-loop": "~0.3.0|~0.4.0|^0.5",
"tracy/tracy": "^2.4"
},
"require-dev": {
"phpunit/phpunit": "^5.0 || ^4.8"
}
}
4 changes: 2 additions & 2 deletions src/DeferredShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Clue\React\Shell;

use React\Promise\Deferred;
use React\Stream\CompositeStream;
use React\Stream\DuplexStreamInterface;
use RuntimeException;

class DeferredShell
Expand All @@ -21,7 +21,7 @@ class DeferredShell
private $buffer = '';
private $started = false;

public function __construct(CompositeStream $stream)
public function __construct(DuplexStreamInterface $stream)
{
$this->stream = $stream;

Expand Down
2 changes: 1 addition & 1 deletion tests/DeferredShellTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class DeferredShellTest extends TestCase

public function setUp()
{
$this->stream = $this->getMockBuilder('React\Stream\CompositeStream')->disableOriginalConstructor()->getMock();
$this->stream = $this->getMockBuilder('React\Stream\DuplexStreamInterface')->getMock();
}

public function testExecuteWritesToStream()
Expand Down
22 changes: 14 additions & 8 deletions tests/ProcessLauncherTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use Clue\React\Shell\ProcessLauncher;
use React\Stream\ReadableStream;

class ProcessLauncherTest extends TestCase
{
Expand All @@ -10,15 +9,15 @@ class ProcessLauncherTest extends TestCase

public function setUp()
{
$this->loop = $this->getMock('React\EventLoop\LoopInterface');
$this->loop = $this->createMock('React\EventLoop\LoopInterface');
$this->processLauncher = new ProcessLauncher($this->loop);
}

public function testProcessWillBeStarted()
{
$process = $this->getMockBuilder('React\ChildProcess\Process')->disableOriginalConstructor()->getMock();
$process->stdout = $this->getMock('React\Stream\ReadableStreamInterface');
$process->stdin = $this->getMock('React\Stream\WritableStreamInterface');
$process->stdout = $this->createMock('React\Stream\ReadableStreamInterface');
$process->stdin = $this->createMock('React\Stream\WritableStreamInterface');

$process->expects($this->once())->method('start');

Expand All @@ -27,11 +26,15 @@ public function testProcessWillBeStarted()
$this->assertInstanceOf('Clue\React\Shell\DeferredShell', $shell);
}


public function testClosingStreamTerminatesRunningProcess()
{
$process = $this->getMockBuilder('React\ChildProcess\Process')->disableOriginalConstructor()->getMock();
$process->stdout = new ReadableStream();
$process->stdin = $this->getMock('React\Stream\WritableStreamInterface');
$process->stdout = $this->createMock('React\Stream\ReadableStreamInterface');
$process->stdin = $this->createMock('React\Stream\WritableStreamInterface');

$process->stdout->expects($this->any())->method('isReadable')->willReturn(true);
$process->stdin->expects($this->any())->method('isWritable')->willReturn(true);

$process->expects($this->once())->method('isRunning')->will($this->returnValue(true));
$process->expects($this->once())->method('terminate')->with($this->equalTo(SIGKILL));
Expand All @@ -44,8 +47,11 @@ public function testClosingStreamTerminatesRunningProcess()
public function testClosingStreamOfNonRunningProcessWillNotTerminate()
{
$process = $this->getMockBuilder('React\ChildProcess\Process')->disableOriginalConstructor()->getMock();
$process->stdout = new ReadableStream();
$process->stdin = $this->getMock('React\Stream\WritableStreamInterface');
$process->stdout = $this->createMock('React\Stream\ReadableStreamInterface');
$process->stdin = $this->createMock('React\Stream\WritableStreamInterface');

$process->stdout->expects($this->any())->method('isReadable')->willReturn(true);
$process->stdin->expects($this->any())->method('isWritable')->willReturn(true);

$process->expects($this->once())->method('isRunning')->will($this->returnValue(false));
$process->expects($this->never())->method('terminate');
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function expectCallableOnceParameter($type)
*/
protected function createCallableMock()
{
return $this->getMock('CallableStub');
return $this->createMock('CallableStub');
}

protected function expectPromiseResolve($promise)
Expand Down