VersionPress\Tests\Automation\WpAutomation::exec PHP Method

exec() private method

..")
private exec ( string $command, string $executionPath = null, boolean $debug = false, null | array $env = null ) : string
$command string
$executionPath string Working directory for the command. If null, the path will be determined automatically.
$debug boolean
$env null | array
return string When process execution is not successful
    private function exec($command, $executionPath = null, $debug = false, $env = null)
    {
        $command = $this->rewriteWpCliCommand($command);
        if (!$executionPath) {
            $executionPath = $this->siteConfig->path;
        }
        // Changing env variables for debugging
        // We don't need the xdebug enabled in the subprocesses,
        // but sometimes on the other hand we need it enabled only in the subprocess.
        $isDebug = isset($_SERVER["XDEBUG_CONFIG"]);
        $childEnv = $_SERVER;
        if ($isDebug == $debug) {
            // same as this process
        } elseif ($debug) {
            $childEnv["XDEBUG_CONFIG"] = "idekey=xdebug";
            // turn debug on
        } else {
            unset($childEnv["XDEBUG_CONFIG"]);
            // turn debug off
        }
        $childEnv = array_merge($childEnv, (array) $env);
        $process = new Process($command, $executionPath, $childEnv);
        $process->run();
        if (!$process->isSuccessful()) {
            throw new Exception("Error executing cmd '{$command}' from working directory " . "'{$executionPath}':\n{$process->getConsoleOutput()}");
        }
        return $process->getOutput();
    }