You are here

public function PHPUnit_Util_PHP_Default::runJob in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/phpunit/phpunit/src/Util/PHP/Default.php \PHPUnit_Util_PHP_Default::runJob()

Runs a single job (PHP code) using a separate PHP process.

Parameters

string $job:

array $settings:

Return value

array

Throws

PHPUnit_Framework_Exception

Overrides PHPUnit_Util_PHP::runJob

1 method overrides PHPUnit_Util_PHP_Default::runJob()
PHPUnit_Util_PHP_Windows::runJob in vendor/phpunit/phpunit/src/Util/PHP/Windows.php
Reading from STDOUT or STDERR hangs forever on Windows if the output is too large.

File

vendor/phpunit/phpunit/src/Util/PHP/Default.php, line 28

Class

PHPUnit_Util_PHP_Default
Default utility for PHP sub-processes.

Code

public function runJob($job, array $settings = array()) {
  $runtime = new Runtime();
  $process = proc_open($runtime
    ->getBinary() . $this
    ->settingsToParameters($settings), 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 spawn worker process');
  }
  $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();
  return array(
    'stdout' => $stdout,
    'stderr' => $stderr,
  );
}