diff --git a/.travis.yml b/.travis.yml index d6e1dfe..ea468ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/composer.json b/composer.json index 040bd50..37f98d2 100644 --- a/composer.json +++ b/composer.json @@ -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" } } diff --git a/src/DeferredShell.php b/src/DeferredShell.php index 7c2446e..8ec1194 100644 --- a/src/DeferredShell.php +++ b/src/DeferredShell.php @@ -3,7 +3,7 @@ namespace Clue\React\Shell; use React\Promise\Deferred; -use React\Stream\CompositeStream; +use React\Stream\DuplexStreamInterface; use RuntimeException; class DeferredShell @@ -21,7 +21,7 @@ class DeferredShell private $buffer = ''; private $started = false; - public function __construct(CompositeStream $stream) + public function __construct(DuplexStreamInterface $stream) { $this->stream = $stream; diff --git a/tests/DeferredShellTest.php b/tests/DeferredShellTest.php index 9db4a13..8fd8ad4 100644 --- a/tests/DeferredShellTest.php +++ b/tests/DeferredShellTest.php @@ -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() diff --git a/tests/ProcessLauncherTest.php b/tests/ProcessLauncherTest.php index b5f7db0..a4f8ca9 100644 --- a/tests/ProcessLauncherTest.php +++ b/tests/ProcessLauncherTest.php @@ -1,7 +1,6 @@ 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'); @@ -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)); @@ -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'); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index fed1e6d..9324857 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -58,7 +58,7 @@ protected function expectCallableOnceParameter($type) */ protected function createCallableMock() { - return $this->getMock('CallableStub'); + return $this->createMock('CallableStub'); } protected function expectPromiseResolve($promise)