Permalink
Browse files

- Call version_compare(), phpinfo(), extension_loaded(), and

  xdebug_is_enabled() only once instead of once per test.
  • Loading branch information...
1 parent bccb93c commit 3eeba928c8ce93f7d86e0fa9c16717d2f7d3ee9f @sebastianbergmann committed May 28, 2007
Showing with 23 additions and 7 deletions.
  1. +23 −7 PHPUnit/Framework/TestResult.php
@@ -69,6 +69,11 @@
*/
class PHPUnit_Framework_TestResult implements Countable
{
+ protected static $isPHP52 = null;
+ protected static $xdebugLoaded = null;
+ protected static $xdebugEnabled = null;
+ protected static $useXdebug = null;
+
/**
* @var array
* @access protected
@@ -503,7 +508,15 @@ public function run(PHPUnit_Framework_Test $test)
$errorHandlerSet = FALSE;
- if (version_compare(phpversion(), '5.2.0RC1', '>=')) {
+ 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);
@@ -515,16 +528,19 @@ public function run(PHPUnit_Framework_Test $test)
restore_error_handler();
}
- $xdebugLoaded = extension_loaded('xdebug');
- $xdebugEnabled = $xdebugLoaded && xdebug_is_enabled();
+ if (self::$xdebugLoaded === NULL) {
+ self::$xdebugLoaded = extension_loaded('xdebug');
+ self::$xdebugEnabled = self::$xdebugLoaded && xdebug_is_enabled();
+ self::$useXdebug = self::$xdebugLoaded && !defined('PHPUnit_INSIDE_OWN_TESTSUITE');
+ }
- if ($xdebugEnabled) {
+ if (self::$xdebugEnabled) {
xdebug_disable();
}
- $useXdebug = ($xdebugLoaded && $this->collectCodeCoverageInformation && !$test instanceof PHPUnit_Extensions_SeleniumTestCase);
+ $useXdebug = self::$useXdebug && $this->collectCodeCoverageInformation && !$test instanceof PHPUnit_Extensions_SeleniumTestCase;
- if ($useXdebug && !defined('PHPUnit_INSIDE_OWN_TESTSUITE')) {
+ if ($useXdebug) {
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
}
@@ -557,7 +573,7 @@ public function run(PHPUnit_Framework_Test $test)
}
}
- if ($xdebugEnabled) {
+ if (self::$xdebugEnabled) {
xdebug_enable();
}

0 comments on commit 3eeba92

Please sign in to comment.