You are here

protected function DistributionProfileTranslationQueryTest::prepareEnvironment in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php \Drupal\FunctionalTests\Installer\DistributionProfileTranslationQueryTest::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/DistributionProfileTranslationQueryTest.php, line 36

Class

DistributionProfileTranslationQueryTest
Tests distribution profile support with a 'langcode' query string.

Namespace

Drupal\FunctionalTests\Installer

Code

protected function prepareEnvironment() {
  parent::prepareEnvironment();
  $this->info = [
    'type' => 'profile',
    'core_version_requirement' => '*',
    'name' => 'Distribution profile',
    'distribution' => [
      'name' => 'My Distribution',
      'langcode' => $this->langcode,
      'install' => [
        'theme' => 'bartik',
      ],
    ],
  ];

  // File API functions are not available yet.
  $path = $this->root . DIRECTORY_SEPARATOR . $this->siteDirectory . '/profiles/mydistro';
  mkdir($path, 0777, TRUE);
  file_put_contents("{$path}/mydistro.info.yml", Yaml::encode($this->info));

  // Place a custom local translation in the translations directory.
  mkdir($this->root . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
  file_put_contents($this->root . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.de.po', $this
    ->getPo('de'));
  file_put_contents($this->root . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.fr.po', $this
    ->getPo('fr'));
}