Browse files

- Merge [5051:5052].

  • Loading branch information...
1 parent b7c5e27 commit f8adcf7efc3f204f67aa31f86bdd2661914df371 @sebastianbergmann committed Jul 31, 2009
Showing with 24 additions and 3 deletions.
  1. +11 −3 PHPUnit/Framework/Process/TestCaseMethod.tpl.dist
  2. +1 −0 PHPUnit/Framework/TestCase.php
  3. +12 −0 PHPUnit/Util/GlobalState.php
View
14 PHPUnit/Framework/Process/TestCaseMethod.tpl.dist
@@ -1,6 +1,16 @@
<?php
function __phpunit_run_isolated_test()
{
+ // Only required for PHPUnit's own test suite.
+ if (!class_exists('PHPUnit_Framework_TestResult')) {
+ require_once 'PHPUnit/Framework.php';
+ }
+
+ // Only required for PHPUnit's own test suite.
+ if (!class_exists('{className}')) {
+ require_once '{filename}';
+ }
+
$result = new PHPUnit_Framework_TestResult;
$result->collectRawCodeCoverageInformation({collectCodeCoverageInformation});
@@ -18,6 +28,7 @@ function __phpunit_run_isolated_test()
);
}
+{included_files}
{constants}
{globals}
set_include_path('{include_path}');
@@ -27,8 +38,5 @@ if (isset($GLOBALS['__PHPUNIT_BOOTSTRAP'])) {
unset($GLOBALS['__PHPUNIT_BOOTSTRAP']);
}
-require_once 'PHPUnit/Framework.php';
-require_once '{filename}';
-
__phpunit_run_isolated_test()
?>
View
1 PHPUnit/Framework/TestCase.php
@@ -567,6 +567,7 @@ public function run(PHPUnit_Framework_TestResult $result = NULL)
'dependencyInput' => addcslashes(serialize($this->dependencyInput), "'"),
'dataName' => $this->dataName,
'collectCodeCoverageInformation' => $collectCodeCoverageInformation ? 'TRUE' : 'FALSE',
+ 'included_files' => PHPUnit_Util_GlobalState::getIncludedFilesAsString(),
'constants' => PHPUnit_Util_GlobalState::getConstantsAsString(),
'globals' => PHPUnit_Util_GlobalState::getGlobalsAsString(),
'include_path' => addslashes(get_include_path())
View
12 PHPUnit/Util/GlobalState.php
@@ -170,6 +170,18 @@ protected static function restoreSuperGlobalArray($superGlobalArray)
self::$globals[$superGlobalArray] = array();
}
+ public static function getIncludedFilesAsString()
+ {
+ $files = get_included_files();
+ $result = '';
+
+ for ($i = count($files) - 1; strpos($files[$i], 'PHPUnit') === FALSE; $i--) {
+ $result = 'require_once \'' . $files[$i] . "';\n" . $result;
+ }
+
+ return $result;
+ }
+
public static function getConstantsAsString()
{
$constants = get_defined_constants(TRUE);

0 comments on commit f8adcf7

Please sign in to comment.