1 backdrop_web_test_case_cache.php | protected BackdropWebTestCaseCache::setUp() |
Sets up a Backdrop site to be used as a cached installation profile.
Overrides BackdropWebTestCase::setUp
File
- core/
modules/ simpletest/ backdrop_web_test_case_cache.php, line 56
Class
- BackdropWebTestCaseCache
- Class for setting up a full installation profile for caching purposes.
Code
protected function setUp() {
global $conf;
// Prepare the environment for running tests.
$this->prepareEnvironment();
if (!$this->setupEnvironment) {
return FALSE;
}
// Reset all statics and variables to perform tests in a clean environment.
$conf = array();
backdrop_static_reset();
// Change the database prefix.
// All static variables need to be reset before the database prefix is
// changed, since BackdropCacheArray implementations attempt to
// write back to persistent caches when they are destructed.
$this->changeDatabasePrefix();
if (!$this->setupDatabasePrefix) {
return FALSE;
}
// Initialize config storage. The database storage needs to be done after
// switching the database prefix.
config_get_config_storage('active')->initializeStorage();
config_get_config_storage('staging')->initializeStorage();
// Preset the 'install_profile' system variable, so the first call into
// system_rebuild_module_data() (in backdrop_install_system()) will register
// the test's profile as a module. Without this, the installation profile of
// the parent site (executing the test) is registered and hook_install() and
// other hook implementations of the test profile are never invoked.
config_install_default_config('system');
config_set('system.core', 'install_profile', $this->profile);
// Perform the actual Backdrop installation.
include_once BACKDROP_ROOT . '/core/includes/install.inc';
backdrop_install_system();
// Set path variables.
$core_config = config('system.core');
$core_config->set('file_default_scheme', 'public');
$core_config->set('file_public_path', $this->public_files_directory);
$core_config->set('file_private_path', $this->private_files_directory);
$core_config->set('file_temporary_path', $this->temp_files_directory);
$core_config->save();
// Ensure schema versions are recalculated.
backdrop_static_reset('backdrop_get_schema_versions');
// Include the testing profile.
config_set('system.core', 'install_profile', $this->profile);
$profile_details = install_profile_info($this->profile, 'en');
// Install the modules specified by the testing profile.
module_enable($profile_details['dependencies'], FALSE);
// Install the profile itself.
$install_profile_module_exists = db_query("SELECT 1 FROM {system} WHERE type = 'module' AND name = :name", array(':name' => $this->profile))->fetchField();
if ($install_profile_module_exists) {
module_enable(array($this->profile), FALSE);
}
return TRUE;
}