3 * This file is part of PHPUnit.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 use SebastianBergmann\Environment\Runtime;
14 * Default utility for PHP sub-processes.
16 * @since Class available since Release 3.5.12
18 class PHPUnit_Util_PHP_Default extends PHPUnit_Util_PHP
21 * Runs a single job (PHP code) using a separate PHP process.
24 * @param array $settings
28 * @throws PHPUnit_Framework_Exception
30 public function runJob($job, array $settings = array())
32 $runtime = new Runtime;
33 $runtime = $runtime->getBinary() . $this->settingsToParameters($settings);
35 if ('phpdbg' === PHP_SAPI) {
36 $runtime .= ' -qrr ' . escapeshellarg(__DIR__ . '/eval-stdin.php');
42 0 => array('pipe', 'r'),
43 1 => array('pipe', 'w'),
44 2 => array('pipe', 'w')
49 if (!is_resource($process)) {
50 throw new PHPUnit_Framework_Exception(
51 'Unable to spawn worker process'
55 $this->process($pipes[0], $job);
58 $stdout = stream_get_contents($pipes[1]);
61 $stderr = stream_get_contents($pipes[2]);
67 return array('stdout' => $stdout, 'stderr' => $stderr);
71 * @param resource $pipe
74 * @throws PHPUnit_Framework_Exception
76 * @since Method available since Release 3.5.12
78 protected function process($pipe, $job)
84 * @since Method available since Release 3.5.12
86 protected function cleanup()