public function testCommandCanRun() { \Amp\run(function () { $process = new Process(self::CMD_PROCESS); $this->assertNull($process->status()); $promise = $process->exec(); $this->assertArrayHasKey('running', $process->status()); $this->assertArrayHasKey('pid', $process->status()); $this->assertTrue($process->status()['running']); $this->assertInternalType('int', $process->pid()); }); }
public function testWatch() { \Amp\run(function () { $process = new Process(self::CMD_PROCESS); $this->assertNull($process->pid()); $promise = $process->exec(); $msg = ""; $promise->watch(function ($update) use(&$msg) { list($type, $partMsg) = $update; $this->assertSame("out", $type); $msg .= $partMsg; }); (yield $promise); $this->assertSame("foo\n", $msg); }); }