You are here

protected function ContentLanguageAccessTestBase::addLanguage in Content Language Access 8

Enables the specified language if it has not been already.

Parameters

string $language_code: The language code to enable.

1 call to ContentLanguageAccessTestBase::addLanguage()
ContentLanguageAccessTestBase::configureLanguages in src/Tests/ContentLanguageAccessTestBase.php
Creates the languages for the test execution.

File

src/Tests/ContentLanguageAccessTestBase.php, line 158

Class

ContentLanguageAccessTestBase
Test the features of content_language_access module.

Namespace

Drupal\content_language_access\Tests

Code

protected function addLanguage($language_code) {

  // Check to make sure that language has not already been installed.
  $this
    ->drupalGet('admin/config/regional/language');
  if (strpos($this
    ->getTextContent(), 'edit-languages-' . $language_code) === FALSE) {

    // Doesn't have language installed so add it.
    $edit = [
      'predefined_langcode' => 'custom',
      'langcode' => $language_code,
      'label' => $language_code,
      'direction' => LanguageInterface::DIRECTION_LTR,
    ];
    $this
      ->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
  }
}