How to test Symfony Process inside a queued job?

Posted 2 years ago by swalker

Hello there,

I am relatively new to testing and so... I have this inside a queued job:

    public function handle()

        $output .= $this->runCommand("ls -la");
     * Runs a command
     * @param        $cmd
     * @param string $cwd
     * @return string
    private function runCommand($cmd, $cwd = '')
        $process = new Process(trim($cmd), $cwd);
        if ( ! $process->isSuccessful()) {
            throw new ProcessFailedException($process);
        return trim($process->getOutput());

How can I test this without actually running the command?

Is it ok if I mock the Proccess class inside my code?

Please sign in or create an account to participate in this conversation.