} catch (dml_connection_exception $e) { $dbinfos[$i]['configured'] = false; } } if (!empty($tests)) { $covreporter = new moodle_coverage_reporter('Functional DB Tests Code Coverage Report', 'dbtest'); $covrecorder = new moodle_coverage_recorder($covreporter); foreach ($tests as $i => $database) { $dbinfo = $dbinfos[$i]; $UNITTEST->func_test_db = $database; // pass the db to the tests through global echo $OUTPUT->heading('Running tests on: ' . $dbinfo['name'], 3); // TODO: localise // Create the group of tests. $test = new autogroup_test_coverage(false, true, $codecoverage); $test->addTestFile($CFG->libdir . '/dml/simpletest/testdml.php'); $test->addTestFile($CFG->libdir . '/ddl/simpletest/testddl.php'); // Make the reporter, which is what displays the results. $reporter = new ExHtmlReporter($showpasses); set_time_limit(300); // 5 mins per DB should be enough $test->run_with_external_coverage($reporter, $covrecorder); unset($UNITTEST->func_test_db); echo '<hr />'; } if ($codecoverage) { $covrecorder->generate_report(); moodle_coverage_reporter::print_summary_info('dbtest'); } } // Print the form for adjusting options.
if ($showsearch) { echo $OUTPUT->heading('Searching for test cases'); } flush(); // Work out what to test. if (substr($path, 0, 1) == '/') { $path = substr($path, 1); } $path = $CFG->dirroot . '/' . $path; if (substr($path, -1) == '/') { $path = substr($path, 0, -1); } $displaypath = substr($path, strlen($CFG->dirroot) + 1); $ok = true; if (is_file($path)) { $test->addTestFile($path); } else { if (is_dir($path)) { $test->findTestFiles($path); } else { echo $OUTPUT->box(get_string('pathdoesnotexist', 'tool_unittest', $path), 'errorbox'); $ok = false; } } // If we have something to test, do it. if ($ok) { if ($path == $CFG->dirroot) { $title = get_string('moodleunittests', 'tool_unittest', get_string('all', 'tool_unittest')); } else { $title = get_string('moodleunittests', 'tool_unittest', $displaypath); }