From 2319bdedd6cb9836f71bcad821abb83efaa5080e Mon Sep 17 00:00:00 2001 From: Eloy Lafuente Date: Mon, 30 Nov 2009 23:18:34 +0000 Subject: [PATCH] MDL-21007 UnitTestCaseUsingDatabase misconfigured unit tests now reported as skipped --- admin/report/unittest/ex_reporter.php | 11 ++++++++++- lang/en_utf8/simpletest.php | 1 + lib/simpletestlib/test_case.php | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/admin/report/unittest/ex_reporter.php b/admin/report/unittest/ex_reporter.php index 9ea83b1cd9b..39a6297d449 100644 --- a/admin/report/unittest/ex_reporter.php +++ b/admin/report/unittest/ex_reporter.php @@ -68,6 +68,15 @@ class ExHtmlReporter extends HtmlReporter { $this->_paintPassFail('fail', $message); } + /** + * Called when a skip needs to be output. + */ + function paintSkip($message) { + // Explicitly call grandparent, not parent::paintFail. + SimpleScorer::paintSkip($message); + $this->_paintPassFail('skip', $message); + } + /** * Called when an error (uncaught exception or PHP error) needs to be output. */ @@ -78,7 +87,7 @@ class ExHtmlReporter extends HtmlReporter { } /** - * Private method. Used by printPass/Fail/Error. + * Private method. Used by printPass/Fail/Skip/Error. */ function _paintPassFail($passorfail, $message, $rawmessage=false) { global $FULLME, $CFG, $OUTPUT; diff --git a/lang/en_utf8/simpletest.php b/lang/en_utf8/simpletest.php index 47bf704e2d1..1629a7d08db 100644 --- a/lang/en_utf8/simpletest.php +++ b/lang/en_utf8/simpletest.php @@ -40,6 +40,7 @@ $string['runtests'] = 'Run tests'; $string['rununittests'] = 'Run the unit tests'; $string['showpasses'] = 'Show passes as well as fails.'; $string['showsearch'] = 'Show the search for test files.'; +$string['skip'] = 'Skip'; $string['stacktrace'] = 'Stack trace:'; $string['summary'] = '{$a->run}/{$a->total} test cases complete: {$a->passes} passes, {$a->fails} fails and {$a->exceptions} exceptions.'; $string['tablesnotsetup'] = 'Unit test tables are not yet built. Do you want to build them now?.'; diff --git a/lib/simpletestlib/test_case.php b/lib/simpletestlib/test_case.php index 350168c3c84..c812e7fd54d 100644 --- a/lib/simpletestlib/test_case.php +++ b/lib/simpletestlib/test_case.php @@ -604,6 +604,7 @@ class TestSuite { } if (is_subclass_of($class, 'UnitTestCaseUsingDatabase') && empty($CFG->unittestprefix)) { // Do not execute this test because $CFG->unittestprefix is not set, but it will be required. + $reporter->paintSkip("Unit test \"{$class}\" of type UnitTestCaseUsingDatabase skipped. Must define different, non-conflicting \$CFG->unittestprefix to be runnable."); continue; } if ($currenttl = @ini_get('max_execution_time')) {