} } 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'); } }
// find the unit test which is running slowly, and either make it faster, // split it into multiple tests, or call set_time_limit within that test. define('TIME_ALLOWED_PER_UNIT_TEST', 60); // Print the header. $strtitle = get_string('unittests', 'tool_unittest'); if (!is_null($path)) { //trim so user doesn't get an error if they include a space on the end of the path (ie by pasting path) $path = trim($path); // Turn off xmlstrictheaders during the unit test run. $origxmlstrictheaders = !empty($CFG->xmlstrictheaders); $CFG->xmlstrictheaders = false; echo $OUTPUT->header(); $CFG->xmlstrictheaders = $origxmlstrictheaders; unset($origxmlstrictheaders); // Create the group of tests. $test = new autogroup_test_coverage($showsearch, true, $codecoverage, 'Moodle Unit Tests Code Coverage Report', 'unittest'); // OU specific. We use the _nonproject folder for stuff we want to // keep in CVS, but which is not really relevant. It does no harm // to leave this here. $test->addIgnoreFolder($CFG->dirroot . '/_nonproject'); // Make the reporter, which is what displays the results. $reporter = new ExHtmlReporter($showpasses); 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;