diff --git a/dev/FunctionalTest.php b/dev/FunctionalTest.php index a27820ef5..459fdf24d 100644 --- a/dev/FunctionalTest.php +++ b/dev/FunctionalTest.php @@ -57,6 +57,9 @@ class FunctionalTest extends SapphireTest { } function setUp() { + // Skip calling FunctionalTest directly. + if(get_class($this) == "FunctionalTest") self::$skip_test = true; + parent::setUp(); $this->mainSession = new TestSession(); @@ -70,7 +73,7 @@ class FunctionalTest extends SapphireTest { // Unprotect the site, tests are running with the assumption it's off. They will enable it on a case-by-case basis. BasicAuth::protect_entire_site(false); - + SecurityToken::disable(); } diff --git a/dev/SapphireTest.php b/dev/SapphireTest.php index 6f55b7739..bebe98713 100644 --- a/dev/SapphireTest.php +++ b/dev/SapphireTest.php @@ -19,6 +19,13 @@ class SapphireTest extends PHPUnit_Framework_TestCase { */ static $fixture_file = null; + /** + * Set whether to include this test in the TestRunner or to skip this. + * + * @var bool + */ + private static $skip_test = false; + /** * @var Boolean If set to TRUE, this will force a test database to be generated * in {@link setUp()}. Note that this flag is overruled by the presence of a @@ -93,6 +100,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase { * Helper arrays for illegalExtensions/requiredExtensions code */ private $extensionsToReapply = array(), $extensionsToRemove = array(); + /** * Determines if unit tests are currently run (via {@link TestRunner}). @@ -113,6 +121,18 @@ class SapphireTest extends PHPUnit_Framework_TestCase { protected $fixtures; function setUp() { + // We cannot run the tests on this abstract class. + if(get_class($this) == "SapphireTest") self::$skip_test = true; + + // Ensure we are to run this test case + if(self::$skip_test) { + $this->markTestSkipped(sprintf( + 'Skipping %s ', get_class($this) + )); + + return; + } + // Mark test as being run $this->originalIsRunningTest = self::$is_running_test; self::$is_running_test = true; diff --git a/dev/TestRunner.php b/dev/TestRunner.php index 167f02e56..94fc8e4ee 100644 --- a/dev/TestRunner.php +++ b/dev/TestRunner.php @@ -234,15 +234,19 @@ class TestRunner extends Controller { self::use_test_manifest(); $classNames = array(); $moduleNames = explode(',', $request->param('ModuleName')); + foreach($moduleNames as $moduleName) { $classesForModule = ClassInfo::classes_for_folder($moduleName); - if($classesForModule) foreach($classesForModule as $class) { - if(class_exists($class) && is_subclass_of($class, 'SapphireTest')) { - $classNames[] = $class; + + if($classesForModule) { + foreach($classesForModule as $className) { + if(class_exists($className) && is_subclass_of($className, 'SapphireTest')) { + $classNames[] = $className; + } } } } - + $this->runTests($classNames, $coverage); }