BUGFIX: Fixed unreliability in SapphireTest::getCurrentAbsolutePath()

This commit is contained in:
Sam Minnee 2012-05-28 14:25:34 +12:00
parent db79739023
commit fb48ec54f4
2 changed files with 30 additions and 3 deletions

View File

@ -43,11 +43,18 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
protected $mailer;
/**
* Pointer to the manifest that isn't a test manifest
*/
protected static $regular_manifest;
/**
* @var boolean
*/
protected static $is_running_test = false;
protected static $test_class_manifest;
/**
* By default, setUp() does not require default records. Pass
* class names in here, and the require/augment default records
@ -114,6 +121,21 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
public static function is_running_test() {
return self::$is_running_test;
}
/**
* Set the manifest to be used to look up test classes by helper functions
*/
public static function set_test_class_manifest($manifest) {
self::$test_class_manifest = $manifest;
}
/**
* Return the manifest being used to look up test classes by helper functions
*/
public static function get_test_class_manifest() {
return self::$test_class_manifest;
}
/**
* @var array $fixtures Array of {@link YamlFixture} instances
@ -422,7 +444,9 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
* @return String Absolute path to current class.
*/
protected function getCurrentAbsolutePath() {
return dirname(SS_ClassLoader::instance()->getManifest()->getItemPath(get_class($this)));
$filename = self::$test_class_manifest->getItemPath(get_class($this));
if(!$filename) throw new LogicException("getItemPath returned null for " . get_class($this));
return dirname($filename);
}
/**

View File

@ -83,9 +83,12 @@ class TestRunner extends Controller {
* top of the loader stacks.
*/
public static function use_test_manifest() {
SS_ClassLoader::instance()->pushManifest(new SS_ClassManifest(
$classManifest = new SS_ClassManifest(
BASE_PATH, true, isset($_GET['flush'])
));
);
SS_ClassLoader::instance()->pushManifest($classManifest);
SapphireTest::set_test_class_manifest($classManifest);
SS_TemplateLoader::instance()->pushManifest(new SS_TemplateManifest(
BASE_PATH, true, isset($_GET['flush'])