} } } if (!empty($tests)) { @ob_implicit_flush(true); while (@ob_end_flush()) { } foreach ($tests as $i => $database) { $dbinfo = $dbinfos[$i]; $UNITTEST->func_test_db = $database; // pass the db to the tests through global print_heading('Running tests on: ' . $dbinfo['name'], '', 3); // TODO: localise // Create the group of tests. $test = new AutoGroupTest(false, true); $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); $test->run($reporter); unset($UNITTEST->func_test_db); echo '<hr />'; } } // Print the form for adjusting options. print_simple_box_start('center', '70%'); echo '<form method="post" action="dbtest.php">'; echo '<div>'; print_heading("Run functional database tests"); // TODO: localise
public function addTestFile($file, $internalcall = false) { global $CFG; if ($this->performcoverage) { $refinfo = moodle_reflect_file($file); require_once $file; if ($refinfo->classes) { foreach ($refinfo->classes as $class) { $reflection = new ReflectionClass($class); if ($staticprops = $reflection->getStaticProperties()) { if (isset($staticprops['includecoverage']) && is_array($staticprops['includecoverage'])) { foreach ($staticprops['includecoverage'] as $toinclude) { $this->add_coverage_include_path($toinclude); } } if (isset($staticprops['excludecoverage']) && is_array($staticprops['excludecoverage'])) { foreach ($staticprops['excludecoverage'] as $toexclude) { $this->add_coverage_exclude_path($toexclude); } } } } // Automatically add the test dir itself, so nothing will be covered there $this->add_coverage_exclude_path(dirname($file)); } } parent::addTestFile($file, $internalcall); }
if ($showsearch) { print_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 { print_simple_box(get_string('pathdoesnotexist', $langfile, $path), '', '', '', '', 'errorbox'); $ok = false; } } // If we have something to test, do it. if ($ok) { if ($path == $CFG->dirroot) { $title = get_string('moodleunittests', $langfile, get_string('all', $langfile)); } else { $title = get_string('moodleunittests', $langfile, $displaypath); }