+++ /dev/null
-<?php
-
-///////////////////////////////////////////////////////////////////////////
-// //
-// NOTICE OF COPYRIGHT //
-// //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment //
-// http://moodle.com //
-// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
-// //
-// This program is free software; you can redistribute it and/or modify //
-// it under the terms of the GNU General Public License as published by //
-// the Free Software Foundation; either version 2 of the License, or //
-// (at your option) any later version. //
-// //
-// This program is distributed in the hope that it will be useful, //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
-// GNU General Public License for more details: //
-// //
-// http://www.gnu.org/copyleft/gpl.html //
-// //
-///////////////////////////////////////////////////////////////////////////
-
-$capabilities = array(
-
- 'report/unittest:view' => array(
- 'riskbitmask' => RISK_DATALOSS,
- 'captype' => 'read',
- 'contextlevel' => CONTEXT_SYSTEM,
- 'archetypes' => array(
- 'manager' => CAP_ALLOW
- ),
-
- 'clonepermissionsfrom' => 'moodle/site:config',
- )
-);
+++ /dev/null
-<?php
-
-defined('MOODLE_INTERNAL') || die;
-
-if ($hassiteconfig) {
- $ADMIN->add('development', new admin_externalpage('reportsimpletest', get_string('simpletest', 'admin'), "$CFG->wwwroot/$CFG->admin/report/unittest/index.php",'report/unittest:view'));
- $ADMIN->add('development', new admin_externalpage('reportdbtest', get_string('dbtest', 'admin'), "$CFG->wwwroot/$CFG->admin/report/unittest/dbtest.php",'report/unittest:view'));
-}
+++ /dev/null
-<?PHP
-
-///////////////////////////////////////////////////////////////////////////
-// //
-// NOTICE OF COPYRIGHT //
-// //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment //
-// http://moodle.com //
-// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
-// //
-// This program is free software; you can redistribute it and/or modify //
-// it under the terms of the GNU General Public License as published by //
-// the Free Software Foundation; either version 2 of the License, or //
-// (at your option) any later version. //
-// //
-// This program is distributed in the hope that it will be useful, //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
-// GNU General Public License for more details: //
-// //
-// http://www.gnu.org/copyleft/gpl.html //
-// //
-///////////////////////////////////////////////////////////////////////////
-
-$plugin->version = 2010090501;
-$plugin->requires = 2010090501;
-
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
* Syntax: coveragefile.php/path/to/file/file.html
* coveragefile.php?file=path/to/file/file.html
*
- * @package moodlecore
- * @subpackage simpletestcoverage
+ * @package tool
+ * @subpackage unittest
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// disable moodle specific debug messages and any errors in output
define('NO_DEBUG_DISPLAY', true);
-require_once(dirname(__FILE__) . '/../../../config.php');
+require(dirname(__FILE__) . '/../../../config.php');
require_once($CFG->libdir . '/filelib.php');
// basic security, require login + require site config cap
require_login();
-require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
+require_capability('tool/unittest:execute', get_context_instance(CONTEXT_SYSTEM));
// get file requested
$relativepath = get_file_argument();
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Unitest caps.
+ *
+ * @package tool
+ * @subpackage unittest
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$capabilities = array(
+
+ // Note: do not add managers here, unittests are dangerous and not intended for production sites!!!
+
+ 'tool/unittest:execute' => array(
+ 'riskbitmask' => RISK_DATALOSS,
+ 'captype' => 'write', // it writes into database, really!
+ 'contextlevel' => CONTEXT_SYSTEM,
+ 'archetypes' => array(
+ )
+ )
+);
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Post installation and migration code.
+ *
+ * @package tool
+ * @subpackage unittest
+ * @copyright 2011 Petr Skoda {@link http://skodak.org}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+function xmldb_tool_unittest_install() {
+ global $CFG;
+
+ // this is a hack - this plugin used to live in admin/tool/unittest,
+ // we want to remove the orphaned version info and capability
+ // unless there is a new report type with the same name
+
+ if (!file_exists("$CFG->dirroot/report/unittest")) {
+ unset_all_config_for_plugin('report_unittest');
+ capabilities_cleanup('report_unittest');
+ }
+}
<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
/**
* Run database functional tests.
- * @package SimpleTestEx
+ *
+ * @package tool
+ * @subpackage unittest
+ * @copyright 2008 Petr Skoda {@link http://skodak.org}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_OUTPUT_BUFFERING', true);
-require_once(dirname(__FILE__).'/../../../config.php');
+require(dirname(__FILE__) . '/../../../config.php');
require_once($CFG->libdir.'/adminlib.php');
-require_once($CFG->libdir.'/simpletestcoveragelib.php');
+require_once('simpletestlib.php');
+require_once('simpletestcoveragelib.php');
require_once('ex_simple_test.php');
require_once('ex_reporter.php');
$selected = optional_param_array('selected', array(), PARAM_INT);
// Print the header and check access.
-admin_externalpage_setup('reportdbtest');
+admin_externalpage_setup('tooldbtest');
echo $OUTPUT->header();
global $UNITTEST;
echo '<form method="post" action="dbtest.php">';
echo '<div>';
echo $OUTPUT->heading("Run functional database tests"); // TODO: localise
-echo '<p>'.html_writer::checkbox('showpasses', 1, $showpasses, get_string('showpasses', 'simpletest')).'</p>';
+echo '<p>'.html_writer::checkbox('showpasses', 1, $showpasses, get_string('showpasses', 'tool_unittest')).'</p>';
if (moodle_coverage_recorder::can_run_codecoverage()) {
- echo '<p>'.html_writer::checkbox('codecoverage', 1, $codecoverage, get_string('codecoverageanalysis', 'simpletest')).'</p>';
+ echo '<p>'.html_writer::checkbox('codecoverage', 1, $codecoverage, get_string('codecoverageanalysis', 'tool_unittest')).'</p>';
} else {
- echo '<p>'; print_string('codecoveragedisabled', 'simpletest'); echo '<input type="hidden" name="codecoverage" value="0" /></p>';
+ echo '<p>'; print_string('codecoveragedisabled', 'tool_unittest'); echo '<input type="hidden" name="codecoverage" value="0" /></p>';
}
echo '<p><strong>'."Databases:".'</strong></p>';
echo '<ul>';
$CFG->func_test_db_2 = array("native", "mssql", "localhost", "moodleuser", "password", "moodle", "test", null);
</pre>
<p>where order of parameters is: dblibrary, dbtype, dbhost, dbuser, dbpass, dbname, prefix, dboptions</p>';
-echo '<p><input type="submit" value="' . get_string('runtests', 'simpletest') . '" /></p>';
+echo '<p><input type="submit" value="' . get_string('runtests', 'tool_unittest') . '" /></p>';
echo '</div>';
echo '</form>';
echo $OUTPUT->box_end();
<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
/**
* A SimpleTest report format for Moodle.
*
- * @copyright © 2006 The Open University
- * @author N.D.Freear@open.ac.uk, T.J.Hunt@open.ac.uk
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package SimpleTestEx
+ * @package tool
+ * @subpackage unittest
+ * @copyright © 2006 The Open University
+ * @author N.D.Freear@open.ac.uk, T.J.Hunt@open.ac.uk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
foreach ($stacktrace as $frame) {
if (empty($frame['file']) || (strpos($frame['file'], 'simpletestlib') === false &&
strpos($frame['file'], 'simpletestcoveragelib') === false
- && strpos($frame['file'], 'report/unittest') === false)) {
+ && strpos($frame['file'], 'tool/unittest') === false)) {
$filteredstacktrace[] = $frame;
$interestinglines += 1;
$dotsadded = false;
* Look up a lang string in the appropriate file.
*/
function get_string($identifier, $a = NULL) {
- return get_string($identifier, 'simpletest', $a);
+ return get_string($identifier, 'tool_unittest', $a);
}
}
<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
/**
* A SimpleTest GroupTest that automatically finds all the
* test files in a directory tree according to certain rules.
*
- * @copyright © 2006 The Open University
- * @author N.D.Freear@open.ac.uk, T.J.Hunt@open.ac.uk
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package SimpleTestEx
+ * @package tool
+ * @subpackage unittest
+ * @copyright © 2006 The Open University
+ * @author N.D.Freear@open.ac.uk, T.J.Hunt@open.ac.uk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
/**
* Run the unit tests.
*
- * @copyright © 2006 The Open University
- * @author N.D.Freear@open.ac.uk, T.J.Hunt@open.ac.uk
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package SimpleTestEx
+ * @package tool
+ * @subpackage unittest
+ * @copyright © 2006 The Open University
+ * @author N.D.Freear@open.ac.uk, T.J.Hunt@open.ac.uk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_OUTPUT_BUFFERING', true);
-require_once(dirname(__FILE__).'/../../../config.php');
+require(dirname(__FILE__) . '/../../../config.php');
require_once($CFG->libdir.'/adminlib.php');
-require_once($CFG->libdir.'/simpletestcoveragelib.php');
+require_once('simpletestlib.php');
+require_once('simpletestcoveragelib.php');
require_once('ex_simple_test.php');
require_once('ex_reporter.php');
$codecoverage = optional_param('codecoverage', false, PARAM_BOOL);
$showsearch = optional_param('showsearch', false, PARAM_BOOL);
-admin_externalpage_setup('reportsimpletest', '', array('showpasses'=>$showpasses, 'showsearch'=>$showsearch));
+admin_externalpage_setup('toolsimpletest', '', array('showpasses'=>$showpasses, 'showsearch'=>$showsearch));
$unittest = true;
define('TIME_ALLOWED_PER_UNIT_TEST', 60);
// Print the header.
-$strtitle = get_string('unittests', 'simpletest');
+$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)
} else if (is_dir($path)){
$test->findTestFiles($path);
} else {
- echo $OUTPUT->box(get_string('pathdoesnotexist', 'simpletest', $path), 'errorbox');
+ echo $OUTPUT->box(get_string('pathdoesnotexist', 'tool_unittest', $path), 'errorbox');
$ok = false;
}
// If we have something to test, do it.
if ($ok) {
if ($path == $CFG->dirroot) {
- $title = get_string('moodleunittests', 'simpletest', get_string('all', 'simpletest'));
+ $title = get_string('moodleunittests', 'tool_unittest', get_string('all', 'tool_unittest'));
} else {
- $title = get_string('moodleunittests', 'simpletest', $displaypath);
+ $title = get_string('moodleunittests', 'tool_unittest', $displaypath);
}
echo $OUTPUT->heading($title);
$test->run($reporter);
}
- $formheader = get_string('retest', 'simpletest');
+ $formheader = get_string('retest', 'tool_unittest');
} else {
$displaypath = '';
echo $OUTPUT->header();
- $formheader = get_string('rununittests', 'simpletest');
+ $formheader = get_string('rununittests', 'tool_unittest');
}
// Print the form for adjusting options.
echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
echo $OUTPUT->heading($formheader);
echo '<form method="get" action="index.php">';
echo '<fieldset class="invisiblefieldset">';
-echo '<p>'.html_writer::checkbox('showpasses', 1, $showpasses, get_string('showpasses', 'simpletest')).'</p>';
-echo '<p>'.html_writer::checkbox('showsearch', 1, $showsearch, get_string('showsearch', 'simpletest')).'</p>';
+echo '<p>'.html_writer::checkbox('showpasses', 1, $showpasses, get_string('showpasses', 'tool_unittest')).'</p>';
+echo '<p>'.html_writer::checkbox('showsearch', 1, $showsearch, get_string('showsearch', 'tool_unittest')).'</p>';
if (moodle_coverage_recorder::can_run_codecoverage()) {
- echo '<p>'.html_writer::checkbox('codecoverage', 1, $codecoverage, get_string('codecoverageanalysis', 'simpletest')).'</p>';
+ echo '<p>'.html_writer::checkbox('codecoverage', 1, $codecoverage, get_string('codecoverageanalysis', 'tool_unittest')).'</p>';
} else {
- echo '<p>'; print_string('codecoveragedisabled', 'simpletest'); echo '<input type="hidden" name="codecoverage" value="0" /></p>';
+ echo '<p>'; print_string('codecoveragedisabled', 'tool_unittest'); echo '<input type="hidden" name="codecoverage" value="0" /></p>';
}
echo '<p>';
- echo '<label for="path">', get_string('onlytest', 'simpletest'), '</label> ';
+ echo '<label for="path">', get_string('onlytest', 'tool_unittest'), '</label> ';
echo '<input type="text" id="path" name="path" value="', $displaypath, '" size="40" />';
echo '</p>';
-echo '<input type="submit" value="' . get_string('runtests', 'simpletest') . '" />';
+echo '<input type="submit" value="' . get_string('runtests', 'tool_unittest') . '" />';
echo '</fieldset>';
echo '</form>';
echo $OUTPUT->box_end();
+$otherpages = array();
+$otherpages['PDF lib test'] = new moodle_url('/admin/tool/unittest/other/pdflibtestpage.php');
+if (debugging('', DEBUG_DEVELOPER)) {
+ $otherpages['TODO checker'] = new moodle_url('/admin/tool/unittest/other/todochecker.php');
+}
+
+// print list of extra test pages that are not simpletests,
+// not everything there is good enough to show to our users
+if ($otherpages) {
+ echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
+ echo $OUTPUT->heading(get_string('othertestpages', 'tool_unittest'));
+ echo '<ul>';
+ foreach ($otherpages as $name=>$url) {
+ echo '<li>'.html_writer::link($url, $name).'</li>';
+ }
+ echo '</ul>';
+ echo $OUTPUT->box_end();
+}
+
+
// Print link to latest code coverage for this report type
if (is_null($path) || !$codecoverage) {
moodle_coverage_reporter::print_link_to_latest('unittest');
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * Strings for component 'simpletest', language 'en', branch 'MOODLE_20_STABLE'
+ * Strings for component 'tool_unittest', language 'en', branch 'MOODLE_22_STABLE'
+ *
+ * This file contains strings that were previously located in lang/en/simpletest.php
*
- * @package simpletest
- * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package tool
+ * @subpackage unittest
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['addconfigprefix'] = 'Add prefix to config file';
$CFG->unittestprefix = \'tst_\' // Change tst_ to a prefix of your choice, different from $CFG->prefix';
$string['coveredlines'] = 'Covered lines';
$string['coveredpercentage'] = 'Overall code coverage';
+$string['dbtest'] = 'Functional DB tests';
$string['deletingnoninsertedrecord'] = 'Trying to delete a record that was not inserted by these unit tests (id {$a->id} in table {$a->table}).';
$string['deletingnoninsertedrecords'] = 'Trying to delete records that were not inserted by these unit tests (from table {$a->table}).';
$string['droptesttables'] = 'Drop test tables';
$string['moodleunittests'] = 'Moodle unit tests: {$a}';
$string['notice'] = 'Notice';
$string['onlytest'] = 'Only run tests in';
+$string['othertestpages'] = 'Other test pages';
$string['pass'] = 'Pass';
$string['pathdoesnotexist'] = 'The path \'{$a}\' does not exist.';
+$string['pluginname'] = 'Unit tests';
$string['prefix'] = 'Unit test tables prefix';
$string['prefixnotset'] = 'The unit test database table prefix is not configured. Fill and submit this form to add it to config.php.';
$string['reinstalltesttables'] = 'Reinstall test tables';
$string['totallines'] = 'Total lines';
$string['uncaughtexception'] = 'Uncaught exception [{$a->getMessage()}] in [{$a->getFile()}:{$a->getLine()}] TESTS ABORTED.';
$string['uncoveredlines'] = 'Uncovered lines';
+$string['unittest:execute'] = 'Execute unit tests';
$string['unittestprefixsetting'] = 'Unit test prefix: <strong>{$a->unittestprefix}</strong> (Edit config.php to modify this).';
$string['unittests'] = 'Unit tests';
$string['updatingnoninsertedrecord'] = 'Trying to update a record that was not inserted by these unit tests (id {$a->id} in table {$a->table}).';
<?php
-
-///////////////////////////////////////////////////////////////////////////
-// //
-// NOTICE OF COPYRIGHT //
-// //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment //
-// http://moodle.org //
-// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
-// //
-// This program is free software; you can redistribute it and/or modify //
-// it under the terms of the GNU General Public License as published by //
-// the Free Software Foundation; either version 2 of the License, or //
-// (at your option) any later version. //
-// //
-// This program is distributed in the hope that it will be useful, //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
-// GNU General Public License for more details: //
-// //
-// http://www.gnu.org/copyleft/gpl.html //
-// //
-///////////////////////////////////////////////////////////////////////////
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
+ * Run the unit tests.
+ *
* A simple test script that sets up test data in the database then
* measures performance of filter_get_active_in_context.
*
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package moodlecore
- *//** */
+ * @copyright 2009 Tim Hunt
+ * @author N.D.Freear@open.ac.uk, T.J.Hunt@open.ac.uk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
-require_once(dirname(__FILE__) . '/../../config.php');
+require(dirname(__FILE__) . '/../../../../config.php');
require_once($CFG->libdir . '/ddllib.php');
require_login();
$syscontext = get_context_instance(CONTEXT_SYSTEM);
-require_capability('moodle/site:config', $syscontext);
+require_capability('tool/unittest:execute', $syscontext);
-$baseurl = $CFG->wwwroot . '/lib/simpletest/filtersettingsperformancetester.php';
+$baseurl = new moodle_url('/admin/tool/unittest/other/filtersettingsperformancetester.php');
$title = 'filter_get_active_in_context performance test';
-$PAGE->set_url('/lib/simpletest/filtersettingsperformancetester.php');
+$PAGE->set_url($baseurl);
+$PAGE->set_context($syscontext);
$PAGE->navbar->add($title);
$PAGE->set_title($title);
$PAGE->set_heading($title);
switch (optional_param('action', '', PARAM_ACTION)) {
case 'setup':
+ require_sesskey();
if ($issetup == 0) {
foreach ($requiredtables as $table) {
$dbman->install_one_table_from_xmldb_file($CFG->dirroot . '/lib/db/install.xml', $table);
break;
case 'teardown':
+ require_sesskey();
foreach ($requiredtables as $tablename) {
$table = new xmldb_table($tablename);
if ($dbman->table_exists($table)) {
break;
case 'test':
+ require_sesskey();
if ($issetup != count($requiredtables)) {
echo $OUTPUT->notification('Something is wrong, please delete the test tables and try again.');
} else {
echo $OUTPUT->container_start();
-$aurl = new moodle_url($baseurl, array('action' => 'setup'));
+$aurl = new moodle_url($baseurl, array('action' => 'setup', 'sesskey'=>sesskey()));
echo $OUTPUT->single_button($aurl, 'Set up test tables', 'get', array('disabled'=>($issetup > 0)));
-$aurl = new moodle_url($baseurl, array('action' => 'teardown'));
+$aurl = new moodle_url($baseurl, array('action' => 'teardown', 'sesskey'=>sesskey()));
echo $OUTPUT->single_button($aurl, 'Drop test tables', 'get', array('disabled'=>($issetup == 0)));
-$aurl = new moodle_url($baseurl, array('action' => 'test'));
+$aurl = new moodle_url($baseurl, array('action' => 'test', 'sesskey'=>sesskey()));
echo $OUTPUT->single_button($aurl, 'Run tests', 'get', array('disabled'=>($issetup != count($requiredtables))));
echo $OUTPUT->container_end();
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
/**
* Pruduces a sample PDF using lib/pdflib.php
*
- * @package moodlecore
+ * @package tool
+ * @subpackage unittest
* @copyright 2009 David Mudrak <david.mudrak@gmail.com>
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @author N.D.Freear@open.ac.uk, T.J.Hunt@open.ac.uk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
+require(dirname(__FILE__) . '/../../../../config.php');
require_once($CFG->libdir . '/pdflib.php');
require_login();
$context = get_context_instance(CONTEXT_SYSTEM);
-require_capability('moodle/site:config', $context);
+require_capability('tool/unittest:execute', $context);
$getpdf = optional_param('getpdf', 0, PARAM_INT);
$fontfamily = optional_param('fontfamily', PDF_DEFAULT_FONT, PARAM_ALPHA); // to be configurable
$doc->SetTitle('Moodle PDF library test');
$doc->SetAuthor('Moodle ' . $CFG->release);
- $doc->SetCreator('lib/simpletest/pdflibtestpage.php');
+ $doc->SetCreator('admin/tool/unittest/pdflibtestpage.php');
$doc->SetKeywords('Moodle, PDF');
$doc->SetSubject('This has been generated by Moodle as its PDF library test page');
$doc->SetMargins(15, 30);
exit();
}
-$PAGE->set_url('/lib/simpletest/pdflibtestpage.php');
+$PAGE->set_url('/admin/tool/unittest/other/pdflibtestpage.php');
$PAGE->set_context($context);
$PAGE->set_title('PDF library test');
$PAGE->set_heading('PDF library test');
// extra security
session_write_close();
- $return_url = "$CFG->wwwroot/$CFG->admin/report/unittest/test_tables.php";
+ $return_url = "$CFG->wwwroot/$CFG->admin/tool/unittest/test_tables.php";
// Temporarily override $DB and $CFG for a fresh install on the unit test prefix
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
*
* As required by http://docs.moodle.org/dev/Coding_style.
*
- * http://docs.moodle.org/dev/Coding_style
- * @package moodlecore
- * @copyright 2009 Tim Hunt
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package tool
+ * @subpackage unittest
+ * @copyright 2009 Tim Hunt
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-require_once(dirname(__FILE__) . '/../../config.php');
-require_once($CFG->libdir . '/simpletestlib.php');
+
+require(dirname(__FILE__) . '/../../../../config.php');
+require_once('../simpletestlib.php');
require_login();
$context = get_context_instance(CONTEXT_SYSTEM);
-require_capability('moodle/site:config', $context);
+require_capability('tool/unittest:execute', $context);
-$PAGE->set_url('/lib/simpletest/todochecker.php');
+$PAGE->set_url('/admin/tool/todochecker.php');
$PAGE->set_context($context);
$PAGE->set_title('To-do checker');
$PAGE->set_heading('To-do checker');
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Unittest settings
+ *
+ * @package tool
+ * @subpackage unittest
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+defined('MOODLE_INTERNAL') || die;
+
+$ADMIN->add('development', new admin_externalpage('toolsimpletest', get_string('pluginname', 'tool_unittest'), "$CFG->wwwroot/$CFG->admin/tool/unittest/index.php", 'tool/unittest:execute'));
+$ADMIN->add('development', new admin_externalpage('tooldbtest', get_string('dbtest', 'tool_unittest'), "$CFG->wwwroot/$CFG->admin/tool/unittest/dbtest.php", 'tool/unittest:execute'));
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
* ones, provide code coverage analysis to already existing tests. Also there are some
* utility functions designed to make the coverage control easier.
*
- * @package core
- * @subpackage simpletestcoverage
+ * @package tool
+ * @subpackage unittest
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Includes
*/
-require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir.'/tablelib.php');
-require_once($CFG->libdir . '/simpletestlib.php');
-require_once($CFG->dirroot . '/' . $CFG->admin . '/report/unittest/ex_simple_test.php');
+require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/unittest/simpletestlib.php');
+require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/unittest/ex_simple_test.php');
require_once($CFG->libdir . '/spikephpcoverage/src/CoverageRecorder.php');
require_once($CFG->libdir . '/spikephpcoverage/src/reporter/HtmlCoverageReporter.php');
$table->id = 'codecoveragetable_' . $type;
$table->rowclasses = array('label', 'value');
$table->data = array(
- array(get_string('date') , userdate($data->time)),
- array(get_string('files') , format_float($data->totalfiles, 0)),
- array(get_string('totallines', 'simpletest') , format_float($data->totalln, 0)),
- array(get_string('executablelines', 'simpletest') , format_float($data->totalcoveredln + $data->totaluncoveredln, 0)),
- array(get_string('coveredlines', 'simpletest') , format_float($data->totalcoveredln, 0)),
- array(get_string('uncoveredlines', 'simpletest') , format_float($data->totaluncoveredln, 0)),
- array(get_string('coveredpercentage', 'simpletest'), format_float($data->totalpercentage, 2) . '%')
+ array(get_string('date') , userdate($data->time)),
+ array(get_string('files') , format_float($data->totalfiles, 0)),
+ array(get_string('totallines', 'tool_unittest') , format_float($data->totalln, 0)),
+ array(get_string('executablelines', 'tool_unittest') , format_float($data->totalcoveredln + $data->totaluncoveredln, 0)),
+ array(get_string('coveredlines', 'tool_unittest') , format_float($data->totalcoveredln, 0)),
+ array(get_string('uncoveredlines', 'tool_unittest') , format_float($data->totaluncoveredln, 0)),
+ array(get_string('coveredpercentage', 'tool_unittest'), format_float($data->totalpercentage, 2) . '%')
);
- $url = $CFG->wwwroot . '/admin/report/unittest/coveragefile.php/' . $type . '/index.html';
+ $url = $CFG->wwwroot . '/'.$CFG->admin.'/tool/unittest/coveragefile.php/' . $type . '/index.html';
$result .= $OUTPUT->heading($data->title, 3, 'main codecoverageheading');
$result .= $OUTPUT->heading('<a href="' . $url . '" onclick="javascript:window.open(' . "'" . $url . "'" . ');return false;"' .
- ' title="">' . get_string('codecoveragecompletereport', 'simpletest') . '</a>', 4, 'main codecoveragelink');
+ ' title="">' . get_string('codecoveragecompletereport', 'tool_unittest') . '</a>', 4, 'main codecoveragelink');
$result .= html_writer::table($table);
return $OUTPUT->box($result, 'generalbox boxwidthwide boxaligncenter codecoveragebox', '', true);
$info->files = format_float($data->totalfiles, 0);
$info->percentage = format_float($data->totalpercentage, 2) . '%';
- $strlatestreport = get_string('codecoveragelatestreport', 'simpletest');
- $strlatestdetails = get_string('codecoveragelatestdetails', 'simpletest', $info);
+ $strlatestreport = get_string('codecoveragelatestreport', 'tool_unittest');
+ $strlatestdetails = get_string('codecoveragelatestdetails', 'tool_unittest', $info);
// return one link to latest complete report
$result = '';
- $url = $CFG->wwwroot . '/admin/report/unittest/coveragefile.php/' . $type . '/index.html';
+ $url = $CFG->wwwroot . '/'.$CFG->admin.'/tool/unittest/coveragefile.php/' . $type . '/index.html';
$result .= $OUTPUT->heading('<a href="' . $url . '" onclick="javascript:window.open(' . "'" . $url . "'" . ');return false;"' .
' title="">' . $strlatestreport . '</a>', 3, 'main codecoveragelink');
$result .= $OUTPUT->heading($strlatestdetails, 4, 'main codecoveragedetails');
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
* Major Contirbutors
* - T.J.Hunt@open.ac.uk
*
- * @package core
- * @subpackage simpletestex
+ * @package tool
+ * @subpackage unittest
* @copyright © 2006 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Includes
*/
-require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir . '/simpletestlib/simpletest.php');
require_once($CFG->libdir . '/simpletestlib/unit_tester.php');
require_once($CFG->libdir . '/simpletestlib/expectation.php');
foreach ($parsererrors as $key => $message) {
$parsererrors[$key] = $message->message;
}
- return 'Could not parse XML [' . $html . '] errors were [' .
+ return 'Could not parse XML [' . $html . '] errors were [' .
implode('], [', $parsererrors) . ']';
}
return $this->customMessage($html);
if (!file_put_contents($this->pkfile, $tabledata)) {
$a = new stdClass();
$a->filename = $this->pkfile;
- throw new moodle_exception('testtablescsvfileunwritable', 'simpletest', '', $a);
+ throw new moodle_exception('testtablescsvfileunwritable', 'tool_unittest', '', $a);
}
}
}
} else {
$a = new stdClass();
$a->filename = $this->pkfile;
- throw new moodle_exception('testtablescsvfilemissing', 'simpletest', '', $a);
+ throw new moodle_exception('testtablescsvfilemissing', 'tool_unittest', '', $a);
return false;
}
}
global $CFG, $DB;
UnitTestDB::$real_db = clone($DB);
if (empty($CFG->unittestprefix)) {
- print_error("prefixnotset", 'simpletest');
+ print_error("prefixnotset", 'tool_unittest');
}
if (empty(UnitTestDB::$DB)) {
$manager = UnitTestDB::$DB->get_manager();
if (!$manager->table_exists('user')) {
- print_error('tablesnotsetup', 'simpletest');
+ print_error('tablesnotsetup', 'tool_unittest');
}
$DB = new UnitTestDB();
$a = new stdClass();
$a->id = $dataobject->id;
$a->table = $table;
- throw new moodle_exception('updatingnoninsertedrecord', 'simpletest', '', $a);
+ throw new moodle_exception('updatingnoninsertedrecord', 'tool_unittest', '', $a);
} else {
return UnitTestDB::$DB->update_record($table, $dataobject, $bulk);
}
if ($proceed_with_delete) {
return UnitTestDB::$DB->delete_records($table, $conditions);
} else {
- throw new moodle_exception('deletingnoninsertedrecord', 'simpletest', '', $a);
+ throw new moodle_exception('deletingnoninsertedrecord', 'tool_unittest', '', $a);
}
}
if ($proceed_with_delete) {
return UnitTestDB::$DB->delete_records_select($table, $select, $params);
} else {
- throw new moodle_exception('deletingnoninsertedrecord', 'simpletest', '', $a);
+ throw new moodle_exception('deletingnoninsertedrecord', 'tool_unittest', '', $a);
}
}
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * Strings for component 'report_unittest', language 'en', branch 'MOODLE_20_STABLE'
+ * Unittest version info
*
- * @package report_unittest
- * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package tool
+ * @subpackage unittest
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-$string['pluginname'] = 'Unit tests';
-$string['unittest:view'] = 'Execute unit tests';
+$plugin->version = 2011091700; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011091600; // Requires this Moodle version
+$plugin->component = 'tool_unittest'; // Full name of the plugin (used for diagnostics)
+
$string['dbmigrationdeprecateddb'] = '<font color="#ff0000">This database is migrated to a new UTF8 database and deprecated. Please edit your config.php and use the new database for this moodle.</font>';
$string['dbmigrationdupfailed'] = 'Database duplication failed with possible error:<font color="#ff0000"><pre>{$a}</pre></font>';
$string['dbsessions'] = 'Use database for session information';
-$string['dbtest'] = 'Functional DB tests';
$string['debug'] = 'Debug messages';
$string['debugall'] = 'ALL: Show all reasonable PHP debug messages';
$string['debugdeveloper'] = 'DEVELOPER: extra Moodle debug messages for developers';
$string['settingsafemode'] = 'Moodle is not fully compatible with safe mode, please ask server administrator to turn it off. Running Moodle under safe mode is not supported, please expect various problems if you do so.';
$string['showcommentscount'] = 'Show comments count';
$string['showdetails'] = 'Show details';
-$string['simpletest'] = 'Unit tests';
$string['simplexmlrequired'] = 'The SimpleXML PHP extension is now required by Moodle.';
$string['sitelangchanged'] = 'Site language setting changed successfully';
$string['sitemaintenance'] = 'The site is undergoing maintenance and is currently not available';
'repository' => 'repository',
'rss' => 'rss',
'role' => $CFG->admin.'/role',
- 'simpletest' => NULL,
'search' => 'search',
'table' => NULL,
'tag' => 'tag',
'report' => array(
'backups', 'configlog', 'courseoverview',
'customlang', 'log', 'questioninstances',
- 'security', 'spamcleaner', 'stats', 'unittest'
+ 'security', 'spamcleaner', 'stats'
),
'repository' => array(
),
'tool' => array(
- 'capability', 'profiling', 'unsuproles'
+ 'capability', 'profiling', 'unittest', 'unsuproles'
),
'webservice' => array(
* Unit tests for the xhtml_container_stack class.
*
* These tests assume that developer debug mode is on, which, at the time of
- * writing, is true. admin/report/unittest/index.php forces it on.
+ * writing, is true. admin/tool/unittest/index.php forces it on.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
public function test_initialise_default_pagetype() {
// Exercise SUT
- $this->testpage->initialise_default_pagetype('admin/report/unittest/index.php');
+ $this->testpage->initialise_default_pagetype('admin/tool/unittest/index.php');
// Validate
$this->assertEqual('admin-report-unittest-index', $this->testpage->pagetype);
}
defined('MOODLE_INTERNAL') || die();
-require_once(dirname(__FILE__) . '/../../../../config.php');
-
global $CFG;
-require_once($CFG->libdir . '/simpletestlib.php'); // Include the test libraries
+
require_once($CFG->dirroot . '/mod/quiz/report/reportlib.php'); // Include the code to test