You are here

class PHPUnit_Util_PHP_Default in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Util/PHP/Default.php \PHPUnit_Util_PHP_Default

Default utility for PHP sub-processes.

@since Class available since Release 3.5.12

Hierarchy

Expanded class hierarchy of PHPUnit_Util_PHP_Default

File

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

View source
class PHPUnit_Util_PHP_Default extends PHPUnit_Util_PHP {

  /**
   * Runs a single job (PHP code) using a separate PHP process.
   *
   * @param  string                      $job
   * @param  array                       $settings
   * @return array
   * @throws PHPUnit_Framework_Exception
   */
  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,
    );
  }

  /**
   * @param  resource                    $pipe
   * @param  string                      $job
   * @throws PHPUnit_Framework_Exception
   * @since Method available since Release 3.5.12
   */
  protected function process($pipe, $job) {
    fwrite($pipe, $job);
  }

  /**
   * @since Method available since Release 3.5.12
   */
  protected function cleanup() {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PHPUnit_Util_PHP::factory public static function @since Method available since Release 3.5.12
PHPUnit_Util_PHP::getException private function Gets the thrown exception from a PHPUnit_Framework_TestFailure.
PHPUnit_Util_PHP::processChildResult private function Processes the TestResult object from an isolated process.
PHPUnit_Util_PHP::runTestJob public function Runs a single test in a separate PHP process.
PHPUnit_Util_PHP::settingsToParameters protected function @since Method available since Release 4.0.0
PHPUnit_Util_PHP_Default::cleanup protected function @since Method available since Release 3.5.12 1
PHPUnit_Util_PHP_Default::process protected function @since Method available since Release 3.5.12 1
PHPUnit_Util_PHP_Default::runJob public function Runs a single job (PHP code) using a separate PHP process. Overrides PHPUnit_Util_PHP::runJob 1