diff --git a/admin/tool/unittest/other/test_tables.php b/admin/tool/unittest/other/test_tables.php deleted file mode 100644 index 61fb6736411..00000000000 --- a/admin/tool/unittest/other/test_tables.php +++ /dev/null @@ -1,94 +0,0 @@ -unittestprefix)) { - die; - } - - $CFG->xmlstrictheaders = false; - - // extra security - session_write_close(); - - $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 - - $real_cfg = $CFG; - - $CFG = new stdClass(); - $CFG->dbhost = $real_cfg->dbhost; - $CFG->dbtype = $real_cfg->dbtype; - $CFG->dblibrary = $real_cfg->dblibrary; - $CFG->dbuser = $real_cfg->dbuser; - $CFG->dbpass = $real_cfg->dbpass; - $CFG->dbname = $real_cfg->dbname; - $CFG->unittestprefix = $real_cfg->unittestprefix; - $CFG->wwwroot = $real_cfg->wwwroot; - $CFG->dirroot = $real_cfg->dirroot; - $CFG->libdir = $real_cfg->libdir; - $CFG->dataroot = $real_cfg->dataroot; - $CFG->admin = $real_cfg->admin; - $CFG->release = $real_cfg->release; - $CFG->version = $real_cfg->version; - $CFG->config_php_settings = $real_cfg->config_php_settings; - $CFG->debug = 0; - - $DB = moodle_database::get_driver_instance($CFG->dbtype, $CFG->dblibrary); - $DB->connect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->unittestprefix); - - $test_tables = $DB->get_tables(); - - include("$CFG->dirroot/version.php"); // defines $version and $release - - /// Check if the main tables have been installed yet or not. - if ($test_tables = $DB->get_tables() ) { // No tables yet at all. - //TODO: make sure these are test tables & delte all these tables - $manager = $DB->get_manager(); - foreach ($test_tables as $table) { - $xmldbtable = new xmldb_table($table); - $manager->drop_table($xmldbtable); - } - } - -/// return to original debugging level - - $DB->get_manager()->install_from_xmldb_file("$CFG->libdir/db/install.xml"); - -/// set all core default records and default settings - require_once("$CFG->libdir/db/install.php"); - xmldb_main_install($version); - -/// Continue with the instalation - - // Install the roles system. - moodle_install_roles(); - - // Install core event handlers - events_update_definition(); - - // Install core message providers - message_update_providers(); - message_update_providers('message'); - - // Write default settings unconditionally (i.e. even if a setting is already set, overwrite it) - admin_apply_default_settings(NULL, true); - - -/// upgrade all plugins types - $plugintypes = get_plugin_types(); - foreach ($plugintypes as $type => $location) { - upgrade_plugins($type); - } - -/// just make sure upgrade logging is properly terminated - upgrade_finished(); - -/// make sure admin user is created - this is the last step because we need -/// session to be working properly in order to edit admin account - create_admin_user(); - - - redirect('index.php'); -*/ \ No newline at end of file diff --git a/admin/tool/unittest/other/pdflibtestpage.php b/lib/tests/other/pdflibtestpage.php similarity index 93% rename from admin/tool/unittest/other/pdflibtestpage.php rename to lib/tests/other/pdflibtestpage.php index 5266bfe4d52..985d175b9f8 100644 --- a/admin/tool/unittest/other/pdflibtestpage.php +++ b/lib/tests/other/pdflibtestpage.php @@ -15,20 +15,19 @@ // along with Moodle. If not, see . /** - * Pruduces a sample PDF using lib/pdflib.php + * Produces a sample PDF using lib/pdflib.php * - * @package tool - * @subpackage unittest + * @package core * @copyright 2009 David Mudrak * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -require(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('tool/unittest:execute', $context); +require_capability('moodle/site:config', $context); $getpdf = optional_param('getpdf', 0, PARAM_INT); $fontfamily = optional_param('fontfamily', PDF_DEFAULT_FONT, PARAM_ALPHA); // to be configurable @@ -54,7 +53,7 @@ if ($getpdf) { $doc->SetTitle('Moodle PDF library test'); $doc->SetAuthor('Moodle ' . $CFG->release); - $doc->SetCreator('admin/tool/unittest/pdflibtestpage.php'); + $doc->SetCreator('lib/tests/other/pdflibtestpage.php'); $doc->SetKeywords('Moodle, PDF'); $doc->SetSubject('This has been generated by Moodle as its PDF library test page'); $doc->SetMargins(15, 30); @@ -133,7 +132,7 @@ if ($getpdf) { exit(); } -$PAGE->set_url('/admin/tool/unittest/other/pdflibtestpage.php'); +$PAGE->set_url('/lib/tests/other/pdflibtestpage.php'); $PAGE->set_context($context); $PAGE->set_title('PDF library test'); $PAGE->set_heading('PDF library test'); diff --git a/admin/tool/unittest/other/todochecker.php b/lib/tests/other/todochecker.php similarity index 85% rename from admin/tool/unittest/other/todochecker.php rename to lib/tests/other/todochecker.php index c9228dbcf57..c22b30a94fb 100644 --- a/admin/tool/unittest/other/todochecker.php +++ b/lib/tests/other/todochecker.php @@ -19,20 +19,18 @@ * * As required by http://docs.moodle.org/dev/Coding_style. * - * @package tool - * @subpackage unittest + * @package core * @copyright 2009 Tim Hunt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -require(dirname(__FILE__) . '/../../../../config.php'); -require_once('../simpletestlib.php'); +require(dirname(__FILE__) . '/../../../config.php'); require_login(); $context = get_context_instance(CONTEXT_SYSTEM); -require_capability('tool/unittest:execute', $context); +require_capability('moodle/site:config', $context); -$PAGE->set_url('/admin/tool/todochecker.php'); +$PAGE->set_url('/lib/tests/other/todochecker.php'); $PAGE->set_context($context); $PAGE->set_title('To-do checker'); $PAGE->set_heading('To-do checker'); @@ -151,4 +149,22 @@ function load_third_party_lib_list() { $libs[$CFG->libdir . '/' . $libobject->location] = 1; } return $libs; -} \ No newline at end of file +} + +function recurseFolders($path, $callback, $fileregexp = '/.*/', $exclude = false, $ignorefolders = array()) { + $files = scandir($path); + + foreach ($files as $file) { + $filepath = $path .'/'. $file; + if (strpos($file, '.') === 0) { + /// Don't check hidden files. + continue; + } else if (is_dir($filepath)) { + if (!in_array($filepath, $ignorefolders)) { + recurseFolders($filepath, $callback, $fileregexp, $exclude, $ignorefolders); + } + } else if ($exclude xor preg_match($fileregexp, $filepath)) { + call_user_func($callback, $filepath); + } + } +} diff --git a/admin/tool/unittest/other/filtersettingsperformancetester.php b/lib/tests/performance/filtersettingsperformancetester.php similarity index 97% rename from admin/tool/unittest/other/filtersettingsperformancetester.php rename to lib/tests/performance/filtersettingsperformancetester.php index aed2eee21aa..c7122c2dab8 100644 --- a/admin/tool/unittest/other/filtersettingsperformancetester.php +++ b/lib/tests/performance/filtersettingsperformancetester.php @@ -25,14 +25,16 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -require(dirname(__FILE__) . '/../../../../config.php'); +die(); //TODO: this needs to be rewritten as standard advanced_testcase + +require(dirname(__FILE__) . '/../../../config.php'); require_once($CFG->libdir . '/ddllib.php'); require_login(); $syscontext = get_context_instance(CONTEXT_SYSTEM); -require_capability('tool/unittest:execute', $syscontext); +require_capability('moodle/site:config', $syscontext); -$baseurl = new moodle_url('/admin/tool/unittest/other/filtersettingsperformancetester.php'); +$baseurl = new moodle_url('/lib/tests/performance/filtersettingsperformancetester.php'); $title = 'filter_get_active_in_context performance test'; $PAGE->set_url($baseurl);