public function LingotekNodeBulkLocaleTranslationTest::testNodeTranslationUsingLinks in Lingotek Translation 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/LingotekNodeBulkLocaleTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkLocaleTranslationTest::testNodeTranslationUsingLinks()
- 4.0.x tests/src/Functional/LingotekNodeBulkLocaleTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkLocaleTranslationTest::testNodeTranslationUsingLinks()
- 3.1.x tests/src/Functional/LingotekNodeBulkLocaleTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkLocaleTranslationTest::testNodeTranslationUsingLinks()
- 3.2.x tests/src/Functional/LingotekNodeBulkLocaleTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkLocaleTranslationTest::testNodeTranslationUsingLinks()
- 3.3.x tests/src/Functional/LingotekNodeBulkLocaleTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkLocaleTranslationTest::testNodeTranslationUsingLinks()
- 3.4.x tests/src/Functional/LingotekNodeBulkLocaleTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkLocaleTranslationTest::testNodeTranslationUsingLinks()
- 3.5.x tests/src/Functional/LingotekNodeBulkLocaleTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkLocaleTranslationTest::testNodeTranslationUsingLinks()
- 3.6.x tests/src/Functional/LingotekNodeBulkLocaleTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkLocaleTranslationTest::testNodeTranslationUsingLinks()
- 3.7.x tests/src/Functional/LingotekNodeBulkLocaleTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkLocaleTranslationTest::testNodeTranslationUsingLinks()
- 3.8.x tests/src/Functional/LingotekNodeBulkLocaleTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkLocaleTranslationTest::testNodeTranslationUsingLinks()
Tests that a node can be translated using the links on the management page.
File
- tests/
src/ Functional/ LingotekNodeBulkLocaleTranslationTest.php, line 60
Class
- LingotekNodeBulkLocaleTranslationTest
- Tests translating a node into locales using the bulk management form.
Namespace
Drupal\Tests\lingotek\FunctionalCode
public function testNodeTranslationUsingLinks() {
// Login as admin.
$this
->drupalLogin($this->rootUser);
// Create a node.
$edit = [];
$edit['title[0][value]'] = 'Llamas are cool';
$edit['body[0][value]'] = 'Llamas are very cool';
$edit['langcode[0][value]'] = 'en';
$edit['lingotek_translation_management[lingotek_translation_profile]'] = 'manual';
$this
->saveAndPublishNodeForm($edit);
$this
->goToContentBulkManagementForm();
// Clicking English must init the upload of content.
$this
->assertLingotekUploadLink();
// And we cannot request yet a translation.
$this
->assertNoLingotekRequestTranslationLink('es_ES');
$this
->assertNoLingotekRequestTranslationLink('es_AR');
$this
->clickLink('EN');
// There is a link for checking status.
$this
->assertLingotekCheckSourceStatusLink();
// And we can already request a translation.
$this
->assertLingotekRequestTranslationLink('es_ES');
$this
->assertLingotekRequestTranslationLink('es_AR');
$this
->clickLink('EN');
$this
->assertText('The import for node Llamas are cool is complete.');
// Request the German (AT) translation.
$this
->assertLingotekRequestTranslationLink('de_AT', 'dummy-document-hash-id');
$this
->clickLink('DE-AT');
$this
->assertText("Locale 'de_AT' was added as a translation target for node Llamas are cool.");
// Check that the requested locale is the right one.
$this
->assertIdentical('de_AT', \Drupal::state()
->get('lingotek.added_target_locale'));
\Drupal::state()
->resetCache();
// Request the Spanish translation.
$this
->assertLingotekRequestTranslationLink('es_ES');
$this
->assertLingotekRequestTranslationLink('es_AR');
$this
->clickLink('ES');
$this
->assertText("Locale 'es_AR' was added as a translation target for node Llamas are cool.");
// Check that the requested locale is the right one.
$this
->assertIdentical('es_AR', \Drupal::state()
->get('lingotek.added_target_locale'));
// Check status of the Spanish translation.
$this
->assertLingotekCheckTargetStatusLink('es_AR');
$this
->clickLink('ES');
$this
->assertText('The es_AR translation for node Llamas are cool is ready for download.');
// Download the Spanish translation.
$this
->assertLingotekDownloadTargetLink('es_AR');
$this
->clickLink('ES');
$this
->assertText('The translation of node Llamas are cool into es_AR has been downloaded.');
// Now the link is to the workbench, and it opens in a new tab.
$this
->assertLingotekWorkbenchLink('es_AR');
// Check that the order of target languages is always alphabetical.
$target_links = $this
->xpath("//a[contains(@class,'language-icon')]");
$this
->assertEqual(count($target_links), 3, 'The three languages appear as targets');
$this
->assertEqual('DE-AT', $target_links[0]
->getHtml(), 'DE-AT is the first language');
$this
->assertEqual('ES', $target_links[1]
->getHtml(), 'ES is the second language');
$this
->assertEqual('ES-ES', $target_links[2]
->getHtml(), 'ES-ES is the third language');
}