NOBUG standardising prevention of output buffering
[moodle.git] / admin / report / unittest / test_tables.php
CommitLineData
db5af934 1<?php
2
3die;die;die;
adfc4d7c 4/*
db5af934 5 if (empty($CFG->unittestprefix)) {
6 die;
7 }
8
9 $CFG->xmlstrictheaders = false;
10
11 // extra security
12 session_write_close();
13
14 $return_url = "$CFG->wwwroot/$CFG->admin/report/unittest/test_tables.php";
15
16 // Temporarily override $DB and $CFG for a fresh install on the unit test prefix
17
18 $real_cfg = $CFG;
19
20 $CFG = new stdClass();
21 $CFG->dbhost = $real_cfg->dbhost;
22 $CFG->dbtype = $real_cfg->dbtype;
23 $CFG->dblibrary = $real_cfg->dblibrary;
24 $CFG->dbuser = $real_cfg->dbuser;
25 $CFG->dbpass = $real_cfg->dbpass;
26 $CFG->dbname = $real_cfg->dbname;
27 $CFG->unittestprefix = $real_cfg->unittestprefix;
28 $CFG->wwwroot = $real_cfg->wwwroot;
29 $CFG->dirroot = $real_cfg->dirroot;
30 $CFG->libdir = $real_cfg->libdir;
31 $CFG->dataroot = $real_cfg->dataroot;
32 $CFG->admin = $real_cfg->admin;
33 $CFG->release = $real_cfg->release;
34 $CFG->version = $real_cfg->version;
35 $CFG->config_php_settings = $real_cfg->config_php_settings;
db5af934 36 $CFG->debug = 0;
37
38 $DB = moodle_database::get_driver_instance($CFG->dbtype, $CFG->dblibrary);
39 $DB->connect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->unittestprefix);
40
41 $test_tables = $DB->get_tables();
42
43 include("$CFG->dirroot/version.php"); // defines $version and $release
44
45 /// Check if the main tables have been installed yet or not.
46 if ($test_tables = $DB->get_tables() ) { // No tables yet at all.
47 //TODO: make sure these are test tables & delte all these tables
48 $manager = $DB->get_manager();
49 foreach ($test_tables as $table) {
50 $xmldbtable = new xmldb_table($table);
51 $manager->drop_table($xmldbtable);
52 }
53 }
54
db5af934 55/// return to original debugging level
56
57 $DB->get_manager()->install_from_xmldb_file("$CFG->libdir/db/install.xml");
58
59/// set all core default records and default settings
60 require_once("$CFG->libdir/db/install.php");
61 xmldb_main_install($version);
62
63/// Continue with the instalation
64
65 // Install the roles system.
66 moodle_install_roles();
67
68 // Install core event handlers
69 events_update_definition();
70
71 // Install core message providers
72 message_update_providers();
73 message_update_providers('message');
74
75 // Write default settings unconditionally (i.e. even if a setting is already set, overwrite it)
76 admin_apply_default_settings(NULL, true);
77
db5af934 78
79/// upgrade all plugins types
db5af934 80 $plugintypes = get_plugin_types();
17da2e6f 81 foreach ($plugintypes as $type => $location) {
82 upgrade_plugins($type);
db5af934 83 }
84
db5af934 85/// just make sure upgrade logging is properly terminated
0cb93a7e 86 upgrade_finished();
db5af934 87
88/// make sure admin user is created - this is the last step because we need
89/// session to be working properly in order to edit admin account
90 create_admin_user();
91
92
c71ade2f 93 redirect('index.php');
adfc4d7c 94*/