You are here

public function LanguageFormTest::testAddingCustomLanguage in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/Form/LanguageFormTest.php \Drupal\Tests\lingotek\Functional\Form\LanguageFormTest::testAddingCustomLanguage()
  2. 4.0.x tests/src/Functional/Form/LanguageFormTest.php \Drupal\Tests\lingotek\Functional\Form\LanguageFormTest::testAddingCustomLanguage()
  3. 3.0.x tests/src/Functional/Form/LanguageFormTest.php \Drupal\Tests\lingotek\Functional\Form\LanguageFormTest::testAddingCustomLanguage()
  4. 3.1.x tests/src/Functional/Form/LanguageFormTest.php \Drupal\Tests\lingotek\Functional\Form\LanguageFormTest::testAddingCustomLanguage()
  5. 3.2.x tests/src/Functional/Form/LanguageFormTest.php \Drupal\Tests\lingotek\Functional\Form\LanguageFormTest::testAddingCustomLanguage()
  6. 3.3.x tests/src/Functional/Form/LanguageFormTest.php \Drupal\Tests\lingotek\Functional\Form\LanguageFormTest::testAddingCustomLanguage()
  7. 3.5.x tests/src/Functional/Form/LanguageFormTest.php \Drupal\Tests\lingotek\Functional\Form\LanguageFormTest::testAddingCustomLanguage()
  8. 3.6.x tests/src/Functional/Form/LanguageFormTest.php \Drupal\Tests\lingotek\Functional\Form\LanguageFormTest::testAddingCustomLanguage()
  9. 3.7.x tests/src/Functional/Form/LanguageFormTest.php \Drupal\Tests\lingotek\Functional\Form\LanguageFormTest::testAddingCustomLanguage()
  10. 3.8.x tests/src/Functional/Form/LanguageFormTest.php \Drupal\Tests\lingotek\Functional\Form\LanguageFormTest::testAddingCustomLanguage()

Tests adding a custom language with a custom locale.

1 call to LanguageFormTest::testAddingCustomLanguage()
LanguageFormTest::testDisablingCustomLanguage in tests/src/Functional/Form/LanguageFormTest.php
Tests disabling for Lingotek a custom language that was enabled.

File

tests/src/Functional/Form/LanguageFormTest.php, line 97

Class

LanguageFormTest
Test the Drupal language form alters.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

public function testAddingCustomLanguage() {

  // Check that there is a select for locales.
  $this
    ->drupalGet('admin/config/regional/language/add');
  $this
    ->assertField('lingotek_locale', 'There is a field for adding the Lingotek locale.');

  // Assert that the locale is empty.
  $this
    ->assertFieldByName('lingotek_locale', '', 'The Lingotek locale is empty by default.');

  // The Lingotek locale is enabled by default.
  $this
    ->getSession()
    ->getPage()
    ->hasUncheckedField('lingotek_disabled');
  $edit = [
    'predefined_langcode' => 'custom',
    'langcode' => 'es-DE',
    'label' => 'Spanish (Germany)',
    'direction' => 'ltr',
    'lingotek_locale' => 'es-ES',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Add custom language');
  $this
    ->assertText('The language Spanish (Germany) has been created and can now be used.');

  // Ensure the language is created and with the right locale.
  $language = ConfigurableLanguage::load('es-DE');
  $this
    ->assertEqual('es_ES', $language
    ->getThirdPartySetting('lingotek', 'locale'), 'The Lingotek locale has been saved successfully.');

  // Ensure the locale and langcode are correctly mapped.

  /** @var LanguageLocaleMapperInterface $locale_mapper */
  $locale_mapper = \Drupal::service('lingotek.language_locale_mapper');
  $this
    ->assertEqual('es_ES', $locale_mapper
    ->getLocaleForLangcode('es-DE'), 'The language locale mapper correctly guesses the locale.');
  $this
    ->assertEqual('es-DE', $locale_mapper
    ->getConfigurableLanguageForLocale('es_ES')
    ->getId(), 'The language locale mapper correctly guesses the langcode.');
}