Beispiel #1
0
 /**
  * Runs a TestCase.
  *
  * @param  PHPUnit_Framework_Test $test
  * @access public
  */
 public function run(PHPUnit_Framework_Test $test)
 {
     $error = FALSE;
     $failure = FALSE;
     $this->startTest($test);
     $errorHandlerSet = FALSE;
     if (self::$isPHP52 === NULL) {
         if (version_compare(phpversion(), '5.2.0RC1', '>=')) {
             self::$isPHP52 = TRUE;
         } else {
             self::$isPHP52 = FALSE;
         }
     }
     if (self::$isPHP52) {
         $oldErrorHandler = set_error_handler('PHPUnit_Util_ErrorHandler', E_RECOVERABLE_ERROR | E_USER_ERROR | E_NOTICE | E_STRICT);
     } else {
         $oldErrorHandler = set_error_handler('PHPUnit_Util_ErrorHandler', E_USER_ERROR | E_NOTICE | E_STRICT);
     }
     if ($oldErrorHandler === NULL) {
         $errorHandlerSet = TRUE;
     } else {
         restore_error_handler();
     }
     if (self::$xdebugLoaded === NULL) {
         self::$xdebugLoaded = extension_loaded('xdebug');
         self::$useXdebug = self::$xdebugLoaded;
     }
     $useXdebug = self::$useXdebug && $this->collectCodeCoverageInformation && !$test instanceof PHPUnit_Extensions_SeleniumTestCase;
     if ($useXdebug) {
         xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
     }
     PHPUnit_Util_Timer::start();
     try {
         $test->runBare();
     } catch (PHPUnit_Framework_AssertionFailedError $e) {
         $failure = TRUE;
     } catch (Exception $e) {
         $error = TRUE;
     }
     $time = PHPUnit_Util_Timer::stop();
     if ($useXdebug) {
         $this->codeCoverageInformation[] = array('test' => $test, 'files' => xdebug_get_code_coverage());
         xdebug_stop_code_coverage();
     }
     if ($errorHandlerSet === TRUE) {
         restore_error_handler();
     }
     if ($error === TRUE) {
         $this->addError($test, $e, $time);
     } else {
         if ($failure === TRUE) {
             $this->addFailure($test, $e, $time);
         }
     }
     $this->endTest($test, $time);
     $this->time += $time;
 }