/** * Installs a site using $CFG->dataroot and $CFG->prefix * @throws coding_exception * @return void */ public static function install_site() { global $DB, $CFG; require_once $CFG->dirroot . '/user/lib.php'; if (!defined('BEHAT_UTIL')) { throw new coding_exception('This method can be only used by Behat CLI tool'); } // New dataroot. self::reset_dataroot(); $options = array(); $options['adminuser'] = '******'; $options['adminpass'] = '******'; $options['fullname'] = self::BEHATSITENAME; $options['shortname'] = self::BEHATSITENAME; install_cli_database($options, false); $frontpagesummary = new admin_setting_special_frontpagedesc(); $frontpagesummary->write_setting(self::BEHATSITENAME); // Update admin user info. $user = $DB->get_record('user', array('username' => 'admin')); $user->email = '*****@*****.**'; $user->firstname = 'Admin'; $user->lastname = 'User'; $user->city = 'Perth'; $user->country = 'AU'; user_update_user($user, false); // Disable email message processor. $DB->set_field('message_processors', 'enabled', '0', array('name' => 'email')); // Sets maximum debug level. set_config('debug', DEBUG_DEVELOPER); set_config('debugdisplay', true); // Keeps the current version of database and dataroot. self::store_versions_hash(); // Stores the database contents for fast reset. self::store_database_state(); }
/** * Installs a site using $CFG->dataroot and $CFG->prefix * @throws coding_exception * @return void */ public static function install_site() { global $DB, $CFG; require_once $CFG->dirroot . '/user/lib.php'; if (!defined('BEHAT_UTIL')) { throw new coding_exception('This method can be only used by Behat CLI tool'); } $tables = $DB->get_tables(false); if (!empty($tables)) { behat_error(BEHAT_EXITCODE_INSTALLED); } // New dataroot. self::reset_dataroot(); $options = array(); $options['adminuser'] = '******'; $options['adminpass'] = '******'; $options['fullname'] = self::BEHATSITENAME; $options['shortname'] = self::BEHATSITENAME; install_cli_database($options, false); // We need to keep the installed dataroot filedir files. // So each time we reset the dataroot before running a test, the default files are still installed. self::save_original_data_files(); $frontpagesummary = new admin_setting_special_frontpagedesc(); $frontpagesummary->write_setting(self::BEHATSITENAME); // Update admin user info. $user = $DB->get_record('user', array('username' => 'admin')); $user->email = '*****@*****.**'; $user->firstname = 'Admin'; $user->lastname = 'User'; $user->city = 'Perth'; $user->country = 'AU'; user_update_user($user, false); // Disable email message processor. $DB->set_field('message_processors', 'enabled', '0', array('name' => 'email')); // Sets maximum debug level. set_config('debug', DEBUG_DEVELOPER); set_config('debugdisplay', 1); // Disable some settings that are not wanted on test sites. set_config('noemailever', 1); // Enable web cron. set_config('cronclionly', 0); // Set editor autosave to high value, so as to avoid unwanted ajax. set_config('autosavefrequency', '604800', 'editor_atto'); // Keeps the current version of database and dataroot. self::store_versions_hash(); // Stores the database contents for fast reset. self::store_database_state(); }
/** * Install a site using $CFG->dataroot and $CFG->prefix * * @return string|bool true on success, else exception code. */ public static function install_site($sitefullname = "Performance test site", $siteshortname = "Performance test site", $adminpass = "******", $adminemail = "*****@*****.**") { global $DB, $CFG; require_once $CFG->dirroot . '/user/lib.php'; if (!defined('PERFORMANCE_SITE_GENERATOR')) { util::performance_exception('This method can be only used by performance site generator.'); } // If already installed, then return with error. $tables = $DB->get_tables(false); if (!empty($tables)) { return self::SITE_ERROR_INSTALLED; } $options = array(); $options['adminuser'] = '******'; $options['adminpass'] = $adminpass; $options['fullname'] = $sitefullname; $options['shortname'] = $siteshortname; install_cli_database($options, false); $frontpagesummary = new \admin_setting_special_frontpagedesc(); $frontpagesummary->write_setting($sitefullname); // Update admin user info. $user = $DB->get_record('user', array('username' => 'admin')); $user->email = $adminemail; $user->firstname = 'Admin'; $user->lastname = 'User'; $user->city = 'Perth'; $user->country = 'AU'; user_update_user($user, false); // Disable email message processor. $DB->set_field('message_processors', 'enabled', '0', array('name' => 'email')); // Disable some settings that are not wanted on test sites. set_config('noemailever', 1); // Enable web cron. set_config('cronclionly', 0); $CFG->dboptions = array('dbpersist' => 1); // Keeps the current version of components hash. self::store_versions_hash(); }