From 0c78935db4289175085d961427316c57d471b440 Mon Sep 17 00:00:00 2001 From: ajshort Date: Fri, 18 Mar 2011 17:38:02 +1100 Subject: [PATCH] API CHANGE: Replaced ManifestBuilder::load_test_manifest() calls with new function TestRunner::use_test_manifest(), which pushes a test manifest onto the class loader. --- dev/CodeViewer.php | 2 +- dev/TestRunner.php | 24 +++++++++++++++++------- tests/FullTestSuite.php | 2 +- tests/bootstrap.php | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) mode change 100755 => 100644 tests/bootstrap.php diff --git a/dev/CodeViewer.php b/dev/CodeViewer.php index 29390bc41..d02e27eab 100644 --- a/dev/CodeViewer.php +++ b/dev/CodeViewer.php @@ -87,7 +87,7 @@ class CodeViewer extends Controller { parent::init(); if(!Permission::check('ADMIN')) return Security::permissionFailure(); - ManifestBuilder::load_test_manifest(); + TestRunner::use_test_manifest(); } public function browse() { diff --git a/dev/TestRunner.php b/dev/TestRunner.php index 92b831bfc..b6224d442 100644 --- a/dev/TestRunner.php +++ b/dev/TestRunner.php @@ -79,7 +79,17 @@ class TestRunner extends Controller { if (is_string($reporter)) $reporter = new $reporter; self::$default_reporter = $reporter; } - + + /** + * Pushes a class manifest instance that uses tests onto the top of the + * autoloader stack. + */ + public static function use_test_manifest() { + SS_ClassLoader::instance()->pushManifest(new SS_ClassManifest( + BASE_PATH, true, isset($_GET['flush']) + )); + } + function init() { parent::init(); @@ -102,7 +112,7 @@ class TestRunner extends Controller { * Currently excludes PhpSyntaxTest */ function all($request, $coverage = false) { - ManifestBuilder::load_test_manifest(); + self::use_test_manifest(); $tests = ClassInfo::subclassesFor('SapphireTest'); array_shift($tests); unset($tests['FunctionalTest']); @@ -122,7 +132,7 @@ class TestRunner extends Controller { * Run test classes that should be run before build - i.e., everything possible. */ function build() { - ManifestBuilder::load_test_manifest(); + self::use_test_manifest(); $tests = ClassInfo::subclassesFor('SapphireTest'); array_shift($tests); unset($tests['FunctionalTest']); @@ -138,7 +148,7 @@ class TestRunner extends Controller { * Browse all enabled test cases in the environment */ function browse() { - ManifestBuilder::load_test_manifest(); + self::use_test_manifest(); self::$default_reporter->writeHeader(); self::$default_reporter->writeInfo('Available Tests', false); if(Director::is_cli()) { @@ -170,7 +180,7 @@ class TestRunner extends Controller { * Run a coverage test across all modules */ function coverageAll($request) { - ManifestBuilder::load_all_classes(); + self::use_test_manifest(); $this->all($request, true); } @@ -197,7 +207,7 @@ class TestRunner extends Controller { * Run only a single test class or a comma-separated list of tests */ function only($request, $coverage = false) { - ManifestBuilder::load_test_manifest(); + self::use_test_manifest(); if($request->param('TestCase') == 'all') { $this->all(); } else { @@ -217,7 +227,7 @@ class TestRunner extends Controller { * A module is generally a toplevel folder, e.g. "mysite" or "sapphire". */ function module($request, $coverage = false) { - ManifestBuilder::load_test_manifest(); + self::use_test_manifest(); $classNames = array(); $moduleNames = explode(',', $request->param('ModuleName')); foreach($moduleNames as $moduleName) { diff --git a/tests/FullTestSuite.php b/tests/FullTestSuite.php index 77e2dc6f9..a1b04e06b 100644 --- a/tests/FullTestSuite.php +++ b/tests/FullTestSuite.php @@ -47,7 +47,7 @@ class FullTestSuite { * @return Array */ public static function get_all_tests() { - ManifestBuilder::load_test_manifest(); + TestRunner::use_test_manifest(); $tests = ClassInfo::subclassesFor('SapphireTest'); array_shift($tests); diff --git a/tests/bootstrap.php b/tests/bootstrap.php old mode 100755 new mode 100644 index be9aef024..ff5d964c5 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -32,4 +32,4 @@ if(!class_exists('Object')) { $_SERVER['REQUEST_URI'] = BASE_URL . '/dev'; -ManifestBuilder::load_test_manifest(); \ No newline at end of file +TestRunner::use_test_manifest(); \ No newline at end of file