1
0
mirror of https://github.com/danog/process.git synced 2024-11-26 20:24:43 +01:00

Add isRunning() test

This commit is contained in:
Aaron Piotrowski 2017-01-15 22:49:41 -06:00
parent aedbcbe339
commit ef6f58a4ce
2 changed files with 16 additions and 2 deletions

View File

@ -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
) {

View File

@ -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());
}));
}