You are here

protected function InstallerNonEnglishProfileWithoutLocaleModuleTest::prepareEnvironment in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php \Drupal\FunctionalTests\Installer\InstallerNonEnglishProfileWithoutLocaleModuleTest::prepareEnvironment()
  2. 10 core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php \Drupal\FunctionalTests\Installer\InstallerNonEnglishProfileWithoutLocaleModuleTest::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.

This method is private as it must only be called once by BrowserTestBase::setUp() (multiple invocations for the same test would have unpredictable consequences) and it must not be callable or overridable by test classes.

Overrides FunctionalTestSetupTrait::prepareEnvironment

File

core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php, line 34

Class

InstallerNonEnglishProfileWithoutLocaleModuleTest
Tests installing a profile with non-English language and no locale module.

Namespace

Drupal\FunctionalTests\Installer

Code

protected function prepareEnvironment() {
  parent::prepareEnvironment();

  // Create a self::PROFILE testing profile that depends on the 'language'
  // module but not on 'locale' module. We set core_version_requirement to '*'
  // for the test so that it does not need to be updated between major
  // versions.
  $profile_info = [
    'type' => 'profile',
    'core_version_requirement' => '*',
    'name' => 'Test with language but without locale',
    'install' => [
      'language',
    ],
  ];

  // File API functions are not available yet.
  $profile_dir = "{$this->root}/{$this->siteDirectory}/profiles/" . self::PROFILE;
  $profile_config_dir = "{$profile_dir}/config/install";
  mkdir($profile_config_dir, 0777, TRUE);
  $profile_info_file = $profile_dir . '/' . static::PROFILE . '.info.yml';
  file_put_contents($profile_info_file, Yaml::encode($profile_info));

  // Copy a non-English language config YAML to be installed with the profile.
  copy($this->root . '/core/profiles/testing_multilingual/config/install/language.entity.de.yml', $profile_config_dir . '/language.entity.de.yml');
}