]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-21007 UnitTestCaseUsingDatabase misconfigured unit tests now reported as skipped
authorEloy Lafuente <stronk7@moodle.org>
Mon, 30 Nov 2009 23:18:34 +0000 (23:18 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Mon, 30 Nov 2009 23:18:34 +0000 (23:18 +0000)
admin/report/unittest/ex_reporter.php
lang/en_utf8/simpletest.php
lib/simpletestlib/test_case.php

index 9ea83b1cd9b107a03178ad61759a1c2285d452d6..39a6297d4498074cf4fb61d9745fee459375b11c 100644 (file)
@@ -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;
index 47bf704e2d1c63cdd05b1e30db9c40f87d0496f6..1629a7d08db2cec9be3dc29eaddc05cd08eb730b 100644 (file)
@@ -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: <strong>{$a->passes}</strong> passes, <strong>{$a->fails}</strong> fails and <strong>{$a->exceptions}</strong> exceptions.';
 $string['tablesnotsetup'] = 'Unit test tables are not yet built. Do you want to build them now?.';
index 350168c3c84b2793db700e7ba618e1eb6c944e5b..c812e7fd54dc1482f989552595b933577bb5bc61 100644 (file)
@@ -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')) {