You are here

protected function LocaleImportFunctionalTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php \Drupal\Tests\locale\Functional\LocaleImportFunctionalTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php, line 48

Class

LocaleImportFunctionalTest
Tests the import of locale files.

Namespace

Drupal\Tests\locale\Functional

Code

protected function setUp() : void {
  parent::setUp();

  // Copy test po files to the translations directory.

  /** @var \Drupal\Core\File\FileSystemInterface $file_system */
  $file_system = \Drupal::service('file_system');
  $file_system
    ->copy(__DIR__ . '/../../../tests/test.de.po', 'translations://', FileSystemInterface::EXISTS_REPLACE);
  $file_system
    ->copy(__DIR__ . '/../../../tests/test.xx.po', 'translations://', FileSystemInterface::EXISTS_REPLACE);
  $this->adminUser = $this
    ->drupalCreateUser([
    'administer languages',
    'translate interface',
    'access administration pages',
  ]);
  $this->adminUserAccessSiteReports = $this
    ->drupalCreateUser([
    'administer languages',
    'translate interface',
    'access administration pages',
    'access site reports',
  ]);
  $this
    ->drupalLogin($this->adminUser);

  // Enable import of translations. By default this is disabled for automated
  // tests.
  $this
    ->config('locale.settings')
    ->set('translation.import_enabled', TRUE)
    ->set('translation.use_source', LOCALE_TRANSLATION_USE_SOURCE_LOCAL)
    ->save();
}