public function LingotekSystemSiteTranslationTest::testLanguageDisabled in Lingotek Translation 4.0.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/LingotekSystemSiteTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteTranslationTest::testLanguageDisabled()
- 3.0.x tests/src/Functional/LingotekSystemSiteTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteTranslationTest::testLanguageDisabled()
- 3.1.x tests/src/Functional/LingotekSystemSiteTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteTranslationTest::testLanguageDisabled()
- 3.2.x tests/src/Functional/LingotekSystemSiteTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteTranslationTest::testLanguageDisabled()
- 3.3.x tests/src/Functional/LingotekSystemSiteTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteTranslationTest::testLanguageDisabled()
- 3.4.x tests/src/Functional/LingotekSystemSiteTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteTranslationTest::testLanguageDisabled()
- 3.5.x tests/src/Functional/LingotekSystemSiteTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteTranslationTest::testLanguageDisabled()
- 3.6.x tests/src/Functional/LingotekSystemSiteTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteTranslationTest::testLanguageDisabled()
- 3.7.x tests/src/Functional/LingotekSystemSiteTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteTranslationTest::testLanguageDisabled()
- 3.8.x tests/src/Functional/LingotekSystemSiteTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteTranslationTest::testLanguageDisabled()
Tests that no translation can be requested if the language is disabled.
File
- tests/
src/ Functional/ LingotekSystemSiteTranslationTest.php, line 152
Class
- LingotekSystemSiteTranslationTest
- Tests translating a config object.
Namespace
Drupal\Tests\lingotek\FunctionalCode
public function testLanguageDisabled() {
$assert_session = $this
->assertSession();
// Add a language.
$italian = ConfigurableLanguage::createFromLangcode('it')
->setThirdPartySetting('lingotek', 'locale', 'it_IT');
$italian
->save();
// Check that the translate tab is in the site information.
$this
->drupalGet('/admin/config/system/site-information');
$this
->clickLink('Translate system information');
$this
->clickLink(t('Upload'));
$this
->assertText(t('System information uploaded successfully'));
// Check that only the configured fields have been uploaded.
$data = json_decode(\Drupal::state()
->get('lingotek.uploaded_content', '[]'), TRUE);
$this
->assertEqual(1, count($data));
$this
->assertTrue(array_key_exists('system.site', $data));
$this
->assertEqual(2, count($data['system.site']));
$this
->assertTrue(array_key_exists('name', $data['system.site']));
$this
->assertTrue(array_key_exists('slogan', $data['system.site']));
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
// Check that the profile used was the right one.
$used_profile = \Drupal::state()
->get('lingotek.used_profile');
$this
->assertIdentical('manual', $used_profile, 'The manual profile was used.');
// The document should have been uploaded, so let's check the upload status.
$this
->clickLink(t('Check upload status'));
$this
->assertText(t('System information status checked successfully'));
// There are two links for requesting translations, or we can add them
// manually.
$assert_session
->linkByHrefExists('/admin/config/system/site-information/translate/it/add');
$assert_session
->linkByHrefExists('/admin/config/system/site-information/translate/es/add');
$assert_session
->linkByHrefExists('/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/it_IT');
$assert_session
->linkByHrefExists('/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/es_AR');
/** @var \Drupal\lingotek\LingotekConfigurationServiceInterface $lingotek_config */
$lingotek_config = \Drupal::service('lingotek.configuration');
$lingotek_config
->disableLanguage($italian);
// Check that the translate tab is in the node.
$this
->drupalGet('/admin/config/system/site-information');
$this
->clickLink('Translate system information');
// Italian is not present anymore, but still can add a translation.
$assert_session
->linkByHrefExists('/admin/config/system/site-information/translate/it/add');
$assert_session
->linkByHrefExists('/admin/config/system/site-information/translate/es/add');
$assert_session
->linkByHrefNotExists('/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/it_IT');
$assert_session
->linkByHrefExists('/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/es_AR');
}