From aa4f6af41a998ace8de73ed0420d7f4415ff39db Mon Sep 17 00:00:00 2001 From: tjhunt Date: Wed, 13 Sep 2006 16:19:56 +0000 Subject: [PATCH] MDL-6542 - Don't run the unit tests until the user is ready. --- admin/report/simpletest/index.php | 103 +++++++++++++++--------------- 1 file changed, 53 insertions(+), 50 deletions(-) diff --git a/admin/report/simpletest/index.php b/admin/report/simpletest/index.php index 90cb0c0b02..f98858344e 100644 --- a/admin/report/simpletest/index.php +++ b/admin/report/simpletest/index.php @@ -19,76 +19,79 @@ require_once('ex_reporter.php'); require_login(); require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID)); -$adminroot = admin_get_root(); -admin_externalpage_setup('reportsimpletest', $adminroot); - - /* The UNITTEST constant can be checked elsewhere if you need to know * when your code is being run as part of a unit test. */ define('UNITTEST', true); $langfile = 'simpletest'; // CGI arguments -$path = optional_param('path', '', PARAM_PATH); +$path = optional_param('path', null, PARAM_PATH); $showpasses = optional_param('showpasses', false, PARAM_BOOL); $showsearch = optional_param('showsearch', false, PARAM_BOOL); $thorough = optional_param('thorough', false, PARAM_BOOL); -// Create the group of tests. -$test =& new AutoGroupTest($showsearch, $thorough); - -// 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); - // Print the header. +$adminroot = admin_get_root(); +admin_externalpage_setup('reportsimpletest', $adminroot); $strtitle = get_string('unittests', $langfile); - admin_externalpage_print_header($adminroot); -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)); +if (!is_null($path)) { + // Create the group of tests. + $test =& new AutoGroupTest($showsearch, $thorough); + + // 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) { + 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 { - $title = get_string('moodleunittests', $langfile, $displaypath); + 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); + } + print_heading($title); + $test->run($reporter); } - print_heading($title); - $test->run($reporter); -} + $formheader = get_string('retest', $langfile); +} else { + $displaypath = ''; + $formheader = get_string('rununittests', $langfile); +} // Print the form for adjusting options. print_simple_box_start('center', '70%'); echo '
'; -print_heading(get_string('retest', $langfile)); +print_heading($formheader); echo '

'; print_checkbox('showpasses', 1, $showpasses, get_string('showpasses', $langfile)); echo '

'; echo '

'; print_checkbox('showsearch', 1, $showsearch, get_string('showsearch', $langfile)); echo '

'; echo '

'; print_checkbox('thorough', 1, $thorough, get_string('thorough', $langfile)); echo '

'; -- 2.39.5