]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-6542 - Don't run the unit tests until the user is ready.
authortjhunt <tjhunt>
Wed, 13 Sep 2006 16:19:56 +0000 (16:19 +0000)
committertjhunt <tjhunt>
Wed, 13 Sep 2006 16:19:56 +0000 (16:19 +0000)
admin/report/simpletest/index.php

index 90cb0c0b0220dc1685cb2ec63b683b9082f09057..f98858344e624b29fd8a4014117b5f4ae9857c58 100644 (file)
@@ -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 '<form method="GET" action="index.php">';
-print_heading(get_string('retest', $langfile));
+print_heading($formheader);
 echo '<p>'; print_checkbox('showpasses', 1, $showpasses, get_string('showpasses', $langfile)); echo '</p>';
 echo '<p>'; print_checkbox('showsearch', 1, $showsearch, get_string('showsearch', $langfile)); echo '</p>';
 echo '<p>'; print_checkbox('thorough', 1, $thorough, get_string('thorough', $langfile)); echo '</p>';