You are here

public function LingotekProfileFormTest::testLanguageDisabled in Lingotek Translation 3.5.x

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

Tests that disabled languages are not shown in the profile form for defining overrides.

File

tests/src/Functional/Form/LingotekProfileFormTest.php, line 523

Class

LingotekProfileFormTest
Tests the Lingotek profile form.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

public function testLanguageDisabled() {
  $assert_session = $this
    ->assertSession();

  /** @var \Drupal\lingotek\LingotekConfigurationServiceInterface $configLingotek */
  $configLingotek = \Drupal::service('lingotek.configuration');

  // Add a language.
  $es = ConfigurableLanguage::createFromLangcode('es')
    ->setThirdPartySetting('lingotek', 'locale', 'es_MX');
  $de = ConfigurableLanguage::createFromLangcode('de')
    ->setThirdPartySetting('lingotek', 'locale', 'de_DE');
  $es
    ->save();
  $de
    ->save();

  /** @var \Drupal\lingotek\LingotekProfileInterface $profile */
  $profile = LingotekProfile::create([
    'id' => strtolower($this
      ->randomMachineName()),
    'label' => $this
      ->randomString(),
  ]);
  $profile
    ->save();
  $profile_id = $profile
    ->id();
  $this
    ->drupalGet("/admin/lingotek/settings/profile/{$profile_id}/edit");
  $this
    ->assertFieldByName('language_overrides[es][overrides]');
  $assert_session
    ->optionExists('edit-language-overrides-de-overrides', 'default');
  $assert_session
    ->optionExists('edit-language-overrides-de-overrides', 'default');

  // We disable a language.
  $configLingotek
    ->disableLanguage($es);

  // The form shouldn't have the field.
  $this
    ->drupalGet("/admin/lingotek/settings/profile/{$profile_id}/edit");
  $this
    ->assertNoFieldByName('language_overrides[es][overrides]');
  $assert_session
    ->optionExists('edit-language-overrides-de-overrides', 'default');

  // We enable the language back.
  $configLingotek
    ->enableLanguage($es);
  $this
    ->drupalGet("/admin/lingotek/settings/profile/{$profile_id}/edit");
  $this
    ->assertFieldByName('language_overrides[es][overrides]');
  $assert_session
    ->optionExists('edit-language-overrides-es-overrides', 'default');
  $assert_session
    ->optionExists('edit-language-overrides-de-overrides', 'default');
}