Runs a single job (PHP code) using a separate PHP process.
string $job:
PHPUnit_Framework_TestCase $test:
PHPUnit_Framework_TestResult $result:
array|null
public function runJob($job, PHPUnit_Framework_Test $test = NULL, PHPUnit_Framework_TestResult $result = NULL) {
$process = proc_open($this
->getPhpBinary(), array(
0 => array(
'pipe',
'r',
),
1 => array(
'pipe',
'w',
),
2 => array(
'pipe',
'w',
),
), $pipes);
if (!is_resource($process)) {
throw new PHPUnit_Framework_Exception('Unable to create process for process isolation.');
}
if ($result !== NULL) {
$result
->startTest($test);
}
$this
->process($pipes[0], $job);
fclose($pipes[0]);
$stdout = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[2]);
proc_close($process);
$this
->cleanup();
if ($result !== NULL) {
$this
->processChildResult($test, $result, $stdout, $stderr);
}
else {
return array(
'stdout' => $stdout,
'stderr' => $stderr,
);
}
}