You are here

public function DomainConfigUITestTrait::createLanguage in Domain Access 8

Creates a second language for testing overrides.

2 calls to DomainConfigUITestTrait::createLanguage()
DomainConfigUIOverrideTest::setUp in domain_config_ui/tests/src/FunctionalJavascript/DomainConfigUIOverrideTest.php
DomainConfigUISettingsTest::setUp in domain_config_ui/tests/src/FunctionalJavascript/DomainConfigUISettingsTest.php
1 method overrides DomainConfigUITestTrait::createLanguage()
DomainConfigUiSavedConfigTest::createLanguage in domain_config_ui/tests/src/FunctionalJavascript/DomainConfigUiSavedConfigTest.php
Creates a second language for testing overrides.

File

domain_config_ui/tests/src/Traits/DomainConfigUITestTrait.php, line 97

Class

DomainConfigUITestTrait
Contains helper classes for tests to set up various configuration.

Namespace

Drupal\Tests\domain_config_ui\Traits

Code

public function createLanguage() {

  // Create and login user.
  $adminUser = $this
    ->drupalCreateUser([
    'administer languages',
    'access administration pages',
  ]);
  $this
    ->drupalLogin($adminUser);

  // Add language.
  $edit = [
    'predefined_langcode' => 'es',
  ];
  $this
    ->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));

  // Enable URL language detection and selection.
  $edit = [
    'language_interface[enabled][language-url]' => '1',
  ];
  $this
    ->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
  $this
    ->drupalLogout();

  // In order to reflect the changes for a multilingual site in the container
  // we have to rebuild it.
  $this
    ->rebuildContainer();
  $es = \Drupal::entityTypeManager()
    ->getStorage('configurable_language')
    ->load('es');
  $this
    ->assertTrue(!empty($es), 'Created test language.');
}