function LocaleImportFunctionalTest::setUp

Same name in other branches
  1. 7.x modules/locale/locale.test \LocaleImportFunctionalTest::setUp()
  2. 8.9.x core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php \Drupal\Tests\locale\Functional\LocaleImportFunctionalTest::setUp()
  3. 10 core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php \Drupal\Tests\locale\Functional\LocaleImportFunctionalTest::setUp()
  4. 11.x 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 47

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();
}

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