function MaintenanceThemeUpdateRegistryTest::prepareEnvironment

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/Theme/MaintenanceThemeUpdateRegistryTest.php \Drupal\Tests\system\Functional\Theme\MaintenanceThemeUpdateRegistryTest::prepareEnvironment()
  2. 11.x core/modules/system/tests/src/Functional/Theme/MaintenanceThemeUpdateRegistryTest.php \Drupal\Tests\system\Functional\Theme\MaintenanceThemeUpdateRegistryTest::prepareEnvironment()

Prepares the current environment for running the test.

Also sets up new resources for the testing environment, such as the public filesystem and configuration directories.

Overrides FunctionalTestSetupTrait::prepareEnvironment

File

core/modules/system/tests/src/Functional/Theme/MaintenanceThemeUpdateRegistryTest.php, line 42

Class

MaintenanceThemeUpdateRegistryTest
Ensures theme update functions are registered for maintenance themes.

Namespace

Drupal\Tests\system\Functional\Theme

Code

protected function prepareEnvironment() {
  parent::prepareEnvironment();
  $info = [
    'type' => 'profile',
    'core_version_requirement' => '*',
    'name' => 'Theme test profile',
    'themes' => [
      'test_theme_updates',
    ],
  ];
  // Create an install profile that uses the test theme.
  $path = $this->siteDirectory . '/profiles/theme_test_profile';
  mkdir($path, 0777, TRUE);
  file_put_contents("{$path}/theme_test_profile.info.yml", Yaml::encode($info));
  // Create a system.theme.yml file for the profile so the test theme is used.
  $path = $this->siteDirectory . '/profiles/theme_test_profile/config/install';
  mkdir($path, 0777, TRUE);
  $theme_config = Yaml::decode(file_get_contents(\Drupal::moduleHandler()->getModule('system')
    ->getPath() . '/config/install/system.theme.yml'));
  $theme_config['default'] = 'test_theme_updates';
  file_put_contents("{$path}/system.theme.yml", Yaml::encode($theme_config));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.