public function LingotekProfileFormTest::testLanguageDisabled in Lingotek Translation 8
Tests that disabled languages are not shown in the profile form for defining overrides.
File
- src/
Tests/ Form/ LingotekProfileFormTest.php, line 357
Class
- LingotekProfileFormTest
- Tests the Lingotek profile form.
Namespace
Drupal\lingotek\Tests\FormCode
public function testLanguageDisabled() {
/** @var 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 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]');
$this
->assertOptionSelected('edit-language-overrides-de-overrides', 'default');
$this
->assertOptionSelected('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]');
$this
->assertOptionSelected('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]');
$this
->assertOptionSelected('edit-language-overrides-es-overrides', 'default');
$this
->assertOptionSelected('edit-language-overrides-de-overrides', 'default');
}