From ef6f58a4cea7314d2389afe47fd4254b49cdcf46 Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Sun, 15 Jan 2017 22:49:41 -0600 Subject: [PATCH] Add isRunning() test --- lib/Process.php | 3 +-- test/ProcessTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/Process.php b/lib/Process.php index 573ee31..aa2cbf5 100644 --- a/lib/Process.php +++ b/lib/Process.php @@ -158,8 +158,7 @@ class Process { $this->stderr = $pipes[2]; $stream = $pipes[3]; - $process = &$this->process; - + $process = $this->process; $this->watcher = Loop::onReadable($stream, static function ($watcher, $resource) use ( $process, $deferred, $stdin ) { diff --git a/test/ProcessTest.php b/test/ProcessTest.php index 14ee981..354f980 100644 --- a/test/ProcessTest.php +++ b/test/ProcessTest.php @@ -19,12 +19,27 @@ class ProcessTest extends \PHPUnit_Framework_TestCase { }); } + public function testIsRunning() { + Loop::execute(\Amp\wrap(function() { + $process = new Process("exit 42"); + $promise = $process->execute(); + + $this->assertTrue($process->isRunning()); + + yield $promise; + + $this->assertFalse($process->isRunning()); + })); + } + + public function testExecuteResolvesToExitCode() { Loop::execute(\Amp\wrap(function() { $process = new Process("exit 42"); $code = yield $process->execute(); $this->assertSame(42, $code); + $this->assertFalse($process->isRunning()); })); }