Bug #5991 - The calendar does not show the month's first day's event; merged from...
[moodle.git] / admin / report / simpletest / index.php
CommitLineData
3ef8c936 1<?php
2/**
3 * Run the unit tests.
4 *
5 * @copyright &copy; 2006 The Open University
6 * @author N.D.Freear@open.ac.uk, T.J.Hunt@open.ac.uk
7 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
8 * @version $Id$
9 * @package SimpleTestEx
10 */
11
12/** */
13require_once(dirname(__FILE__) . '/../../../config.php');
14require_once($CFG->libdir . '/moodlelib.php');
15require_once('ex_simple_test.php');
16require_once('ex_reporter.php');
17
18/* The UNITTEST constant can be checked elsewhere if you need to know
19 * when your code is being run as part of a unit test. */
20define('UNITTEST', true);
21
22require_login();
23if (!isadmin()) {
24 print_error('Only admins can access this page');
25}
26
27// CGI arguments
28$path = optional_param('path', '', PARAM_PATH);
29$showpasses = optional_param('showpasses', false, PARAM_BOOL);
30$showsearch = optional_param('showsearch', false, PARAM_BOOL);
31$thorough = optional_param('thorough', false, PARAM_BOOL);
32
33// Create the group of tests.
34$test =& new AutoGroupTest($showsearch, $thorough);
35
36// OU specific. We use the _nonproject folder for stuff we want to
37// keep in CVS, but which is not really relevant. It does no harm
38// to leave this here.
39$test->addIgnoreFolder($CFG->dirroot . '/_nonproject');
40
41// Make the reporter, which is what displays the results.
42$reporter = new ExHtmlReporter($showpasses);
43
44// Print the header.
45$strtitle = get_string('unittests', 'unittest');
46$stradmin = get_string('administration');
47print_header("$SITE->shortname: $strtitle", $SITE->fullname,
48 '<a href="../../index.php">' . get_string('administration') . '</a> -> ' .
49 '<a href="../../misc.php">' . get_string('miscellaneous') . '</a> -> ' .
50 '<a href="../../report.php">' . get_string('reports') . '</a> -> ' .
51 $strtitle, '', '<style type="text/css">' . $reporter->_getCss() . '</style>');
52if ($showsearch) {
53 print_heading('Searching for test cases');
54}
55flush();
56
57// Work out what to test.
58if (substr($path, 0, 1) == '/') {
59 $path = substr($path, 1);
60}
61$path = $CFG->dirroot . '/' . $path;
62if (substr($path, -1) == '/') {
63 $path = substr($path, 0, -1);
64}
65$displaypath = substr($path, strlen($CFG->dirroot) + 1);
66$ok = true;
67if (is_file($path)) {
68 $test->addTestFile($path);
69} else if (is_dir($path)){
70 $test->findTestFiles($path);
71} else {
72 print_simple_box(get_string('pathdoesnotexist', 'unittest', $path), '', '', '', '', 'errorbox');
73 $ok = false;
74}
75
76// If we have something to test, do it.
77if ($ok) {
78 if ($path == $CFG->dirroot) {
79 $title = get_string('moodleunittests', 'unittest', get_string('all', 'unittest'));
80 } else {
81 $title = get_string('moodleunittests', 'unittest', $displaypath);
82 }
83 print_heading($title);
84 $test->run($reporter);
85}
86
87// Print the form for adjusting options.
88print_simple_box_start('center', '70%');
89echo '<form method="GET" action="index.php">';
90print_heading(get_string('retest', 'unittest'));
91echo '<p>'; print_checkbox('showpasses', 1, $showpasses, get_string('showpasses', 'unittest')); echo '</p>';
92echo '<p>'; print_checkbox('showsearch', 1, $showsearch, get_string('showsearch', 'unittest')); echo '</p>';
93echo '<p>'; print_checkbox('thorough', 1, $thorough, get_string('thorough', 'unittest')); echo '</p>';
94echo '<p>';
95 echo '<label for="path">', get_string('onlytest', 'unittest'), '</label> ';
96 echo '<input type="text" id="path" name="path" value="', $displaypath, '" size="60" />';
97echo '</p>';
98echo '<input type="submit" value="' . get_string('runtests', 'unittest') . '" />';
99echo '</form>';
100print_simple_box_end();
101
102// Footer.
103print_footer();
104
105?>