From 504980ce4d82d86810dc2678b4a21a3b757fd959 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 30 Jun 2009 22:30:33 +0000 Subject: [PATCH] ENHANCEMENT Allowing test runs per module (top-level folder), e.g. sake dev/tests/module/sapphire git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@80645 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- dev/TestRunner.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dev/TestRunner.php b/dev/TestRunner.php index 7ec5179c5..568823389 100644 --- a/dev/TestRunner.php +++ b/dev/TestRunner.php @@ -25,6 +25,8 @@ require_once 'PHPUnit/TextUI/TestRunner.php'; /** * Controller that executes PHPUnit tests. * + * See {@link browse()} output for generic usage instructions. + * * @package sapphire * @subpackage testing */ @@ -38,6 +40,7 @@ class TestRunner extends Controller { 'startsession' => 'startsession', 'endsession' => 'endsession', 'cleanupdb' => 'cleanupdb', + 'module/$ModuleName' => 'module', '$TestCase' => 'only', ); @@ -87,6 +90,7 @@ class TestRunner extends Controller { $relativeLink = Director::makeRelative($this->Link()); echo "sake {$relativeLink}all: Run all " . count($tests) . " tests\n"; echo "sake {$relativeLink}coverage: Runs all tests and make test coverage report\n"; + echo "sake {$relativeLink}module/: Runs all tests in a module folder\n"; foreach ($tests as $test) { echo "sake {$relativeLink}$test: Run $test\n"; } @@ -136,6 +140,23 @@ class TestRunner extends Controller { $this->runTests($classNames); } } + + /** + * Run tests for one or more "modules". + * A module is generally a toplevel folder, e.g. "mysite" or "sapphire". + */ + function module($request) { + $classNames = array(); + $moduleNames = explode(',', $request->param('ModuleName')); + foreach($moduleNames as $moduleName) { + $classesForModule = ClassInfo::classes_for_folder($moduleName); + if($classesForModule) foreach($classesForModule as $class) { + if(is_subclass_of($class, 'SapphireTest')) $classNames[] = $class; + } + } + + $this->runTests($classNames); + } function runTests($classList, $coverage = false) { // XDEBUG seem to cause problems with test execution :-(