public function execute($cmd, $git = true, $cwd = null, $acceptedExitCodes = array(0)) { if ($git) { $cmd = $this->binary->getPath() . ' ' . $cmd; } $process = new Process($cmd, is_null($cwd) ? $this->repositoryPath : $cwd, $this->env); $process->setTimeout(15000); $process->run(); if (!in_array($process->getExitCode(), $acceptedExitCodes)) { $text = 'Exit code: ' . $process->getExitCode(); $text .= ' while executing: "' . $cmd; $text .= '" with reason: ' . $process->getErrorOutput(); $text .= "\n" . $process->getOutput(); throw new \RuntimeException($text); } $this->rawOutput = $process->getOutput(); // rtrim values $values = array_map('rtrim', explode(PHP_EOL, $process->getOutput())); $this->outputLines = $values; return $this; }
public function testConstructor() { $binary = new GitBinary($this->path); $this->assertEquals($this->path, $binary->getPath()); }