I have class responsible for interaction with shell, is there any way I can test functions such as this one with PHPUnit?
public function runCommand($command, $stdin = null)
{
$descriptorspec = array(
array("pipe", "r"), // stdin
array("pipe", "w"), // stdout
array("pipe", "w"), // stderr
);
$environment = array();
$proc = proc_open(
$command,
$descriptorspec,
$pipes,
__DIR__,
$environment
);
if (!is_resource($proc)) {
return false;
}
if ($stdin !== null) {
fwrite($pipes[0], $stdin);
fclose($pipes[0]);
}
$result = stream_get_contents($pipes[1]);
fclose($pipes[1]);
if (proc_close($proc) !== 0) {
return false;
}
return $result;
}
exec()command, with will be the one executing the shell command.$proc = proc_open(runCommand("ls -l /tmp")?