Ejemplo n.º 1
0
 /**
  * Runs a TestCase.
  *
  * @param  PHPUnit2_Framework_Test $test
  * @access public
  */
 public function run(PHPUnit2_Framework_Test $test)
 {
     $this->startTest($test);
     set_error_handler('PHPUnit2_Util_ErrorHandler', E_USER_ERROR);
     $useXdebug = extension_loaded('xdebug') && $this->collectCodeCoverageInformation;
     if ($useXdebug) {
         xdebug_start_code_coverage(XDEBUG_CC_UNUSED);
     }
     $globalsBackup = $GLOBALS;
     try {
         $test->runBare();
     } catch (PHPUnit2_Framework_AssertionFailedError $e) {
         $this->addFailure($test, $e);
     } catch (Exception $e) {
         $this->addError($test, $e);
     }
     $GLOBALS = $globalsBackup;
     if ($useXdebug) {
         $this->codeCoverageInformation[$test->getName()] = PHPUnit2_Util_Filter::getFilteredCodeCoverage(xdebug_get_code_coverage());
         xdebug_stop_code_coverage();
     }
     restore_error_handler();
     $this->endTest($test);
 }
Ejemplo n.º 2
0
 /**
  * Override to run the test and assert its state.
  *
  * @access protected
  */
 protected function runTest()
 {
     self::assertNotNull($this->name);
     try {
         $class = new ReflectionClass($this);
         $method = $class->getMethod($this->name);
     } catch (ReflectionException $e) {
         $this->fail($e->getMessage());
     }
     if (extension_loaded('xdebug')) {
         xdebug_start_code_coverage();
     }
     $method->invoke($this);
     if (extension_loaded('xdebug')) {
         xdebug_stop_code_coverage();
         $this->codeCoverageInformation = PHPUnit2_Util_Filter::getFilteredCodeCoverage(xdebug_get_code_coverage());
     }
 }