public function LingotekContentTypeTranslationTest::testLanguageDisabled in Lingotek Translation 3.1.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/LingotekContentTypeTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeTranslationTest::testLanguageDisabled()
- 4.0.x tests/src/Functional/LingotekContentTypeTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeTranslationTest::testLanguageDisabled()
- 3.0.x tests/src/Functional/LingotekContentTypeTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeTranslationTest::testLanguageDisabled()
- 3.2.x tests/src/Functional/LingotekContentTypeTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeTranslationTest::testLanguageDisabled()
- 3.3.x tests/src/Functional/LingotekContentTypeTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeTranslationTest::testLanguageDisabled()
- 3.4.x tests/src/Functional/LingotekContentTypeTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeTranslationTest::testLanguageDisabled()
- 3.5.x tests/src/Functional/LingotekContentTypeTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeTranslationTest::testLanguageDisabled()
- 3.6.x tests/src/Functional/LingotekContentTypeTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeTranslationTest::testLanguageDisabled()
- 3.7.x tests/src/Functional/LingotekContentTypeTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeTranslationTest::testLanguageDisabled()
- 3.8.x tests/src/Functional/LingotekContentTypeTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeTranslationTest::testLanguageDisabled()
Tests that no translation can be requested if the language is disabled.
File
- tests/
src/ Functional/ LingotekContentTypeTranslationTest.php, line 133
Class
- LingotekContentTypeTranslationTest
- Tests translating a content type.
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();
// Login as admin.
$this
->drupalLogin($this->rootUser);
$this
->drupalGet('/admin/config/regional/config-translation');
$this
->drupalGet('/admin/config/regional/config-translation/node_type');
$this
->clickLink(t('Translate'));
$this
->clickLink(t('Upload'));
$this
->assertText(t('Article uploaded successfully'));
// Check that only the translatable fields have been uploaded.
$data = json_decode(\Drupal::state()
->get('lingotek.uploaded_content', '[]'), TRUE);
$this
->assertEqual(3, count($data));
$this
->assertTrue(array_key_exists('name', $data));
// Cannot use isset, the key exists but we are not providing values, so NULL.
$this
->assertTrue(array_key_exists('description', $data));
$this
->assertTrue(array_key_exists('help', $data));
$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('automatic', $used_profile, 'The automatic profile was used.');
// The document should have been automatically uploaded, so let's check
// the upload status.
$this
->clickLink('Check upload status');
$this
->assertText(t('Article status checked successfully'));
// There are two links for requesting translations, or we can add them
// manually.
$assert_session
->linkByHrefExists('/admin/lingotek/config/request/node_type/article/it_IT');
$assert_session
->linkByHrefExists('/admin/lingotek/config/request/node_type/article/es_MX');
$assert_session
->linkByHrefExists('/admin/structure/types/manage/article/translate/it/add');
$assert_session
->linkByHrefExists('/admin/structure/types/manage/article/translate/es/add');
/** @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/structure/types/manage/article/translate');
// Italian is not present anymore, but still can add a translation.
$assert_session
->linkByHrefNotExists('/admin/lingotek/config/request/node_type/article/it_IT');
$assert_session
->linkByHrefExists('/admin/lingotek/config/request/node_type/article/es_MX');
$assert_session
->linkByHrefExists('/admin/structure/types/manage/article/translate/it/add');
$assert_session
->linkByHrefExists('/admin/structure/types/manage/article/translate/es/add');
}