You are here

protected function LocaleConfigTranslationTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/locale/src/Tests/LocaleConfigTranslationTest.php \Drupal\locale\Tests\LocaleConfigTranslationTest::setUp()

Sets up a Drupal site for running functional and integration tests.

Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.

Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Overrides WebTestBase::setUp

File

core/modules/locale/src/Tests/LocaleConfigTranslationTest.php, line 37
Contains \Drupal\locale\Tests\LocaleConfigTranslationTest.

Class

LocaleConfigTranslationTest
Tests translation of configuration strings.

Namespace

Drupal\locale\Tests

Code

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

  // Add a default locale storage for all these tests.
  $this->storage = $this->container
    ->get('locale.storage');

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

  // Add custom language.
  $this->langcode = 'xx';
  $admin_user = $this
    ->drupalCreateUser(array(
    'administer languages',
    'access administration pages',
    'translate interface',
    'administer modules',
    'access site-wide contact form',
    'administer contact forms',
    'administer site configuration',
  ));
  $this
    ->drupalLogin($admin_user);
  $name = $this
    ->randomMachineName(16);
  $edit = array(
    'predefined_langcode' => 'custom',
    'langcode' => $this->langcode,
    'label' => $name,
    'direction' => LanguageInterface::DIRECTION_LTR,
  );
  $this
    ->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));

  // Set path prefix.
  $edit = [
    "prefix[{$this->langcode}]" => $this->langcode,
  ];
  $this
    ->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
}