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:
parent
aedbcbe339
commit
ef6f58a4ce
@ -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
|
||||
) {
|
||||
|
@ -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());
|
||||
}));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user