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


core/modules/simpletest/backdrop_web_test_case_cache.php, line 56


Class for setting up a full installation profile for caching purposes.


protected function setUp() {
  global $conf;

  // Prepare the environment for running tests.
  if (!$this->setupEnvironment) {
    return FALSE;

  // Reset all statics and variables to perform tests in a clean environment.
  $conf = array();

  // 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.
  if (!$this->setupDatabasePrefix) {
    return FALSE;

  // 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 the test
  // profile's hook_install() and other hook implementations are never invoked.
  config_set('system.core', 'install_profile', $this->profile);

  // Perform the actual Backdrop installation.
  include_once BACKDROP_ROOT . '/core/includes/install.inc';

  // 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);

  // Ensure schema versions are recalculated.

  // 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;