public function test_serialize_with_opts() { $opts = ['--long' => null, '--array' => ['f', 'g'], '--single' => 'z']; $cmd = Command::make('phpunit')->withOptions($opts); $expected = 'phpunit --long --single z --array f g'; $this->assertEquals($expected, substr($cmd->serialize(), 0 - strlen($expected))); }
public function test_kill() { $start = time(); $process = Process::make(Command::make('sleep')->withArgs(5))->runAsync(); usleep(100000); $process->kill(); $this->assertLessThan(5, time() - $start); $this->assertEquals(SIGTERM, $process->getSignal()); }
/** * @param $command * @param array $args * @param array $options * @param array $paths * @param Closure $onSuccess * @param Closure $onError * @return Process */ protected final function buildProcess($command, array $args = [], array $options = [], array $paths = [], Closure $onSuccess = null, Closure $onError = null) { if (in_array($command, static::$subcommands)) { list($command, $subcommand) = explode('-', $command); array_unshift($args, $subcommand); } array_unshift($args, $command); if (!empty($paths)) { $options['--'] = $paths; } $cmd = Command::make('git')->withArgs($args)->withOptions($options); return Process::make($cmd, $this->output)->usingCwd($this->project_dir)->onError($onError)->onSuccess($onSuccess); }