Exemplo n.º 1
0
require_once $CFG->libdir . '/modinfolib.php';
// Cached information on course-module instances
require_once $CFG->dirroot . '/cache/lib.php';
// Cache API
// make sure PHP is not severly misconfigured
setup_validate_php_configuration();
// Connect to the database
setup_DB();
if (PHPUNIT_TEST and !PHPUNIT_UTIL) {
    // make sure tests do not run in parallel
    test_lock::acquire('phpunit');
    $dbhash = null;
    try {
        if ($dbhash = $DB->get_field('config', 'value', array('name' => 'phpunittest'))) {
            // reset DB tables
            phpunit_util::reset_database();
        }
    } catch (Exception $e) {
        if ($dbhash) {
            // we ned to reinit if reset fails
            $DB->set_field('config', 'value', 'na', array('name' => 'phpunittest'));
        }
    }
    unset($dbhash);
}
// Load up any configuration from the config table or MUC cache.
if (PHPUNIT_TEST) {
    phpunit_util::initialise_cfg();
} else {
    initialise_cfg();
}