public function LingotekNodeExistingBulkTranslationTest::testNodeIsUntracked in Lingotek Translation 8
Tests that a node can be translated using the links on the management page.
File
- src/
Tests/ LingotekNodeExistingBulkTranslationTest.php, line 84
Class
- LingotekNodeExistingBulkTranslationTest
- Tests translating a node using the bulk management form.
Namespace
Drupal\lingotek\TestsCode
public function testNodeIsUntracked() {
$this
->goToContentBulkManagementForm();
$basepath = \Drupal::request()
->getBasePath();
// Assert the untracked translation is shown.
$untracked = $this
->xpath("//span[contains(@class,'language-icon') and contains(@class, 'target-untracked') and contains(., 'ES')]");
$this
->assertEqual(count($untracked), 1, 'Untracked translation is shown.');
// Clicking English must init the upload of content.
$this
->assertLinkByHref($basepath . '/admin/lingotek/entity/upload/node/1?destination=' . $basepath . '/admin/lingotek/manage/node');
// And we cannot request yet a translation.
$this
->assertNoLinkByHref($basepath . '/admin/lingotek/entity/add_target/dummy-document-hash-id/es_MX?destination=' . $basepath . '/admin/lingotek/manage/node');
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool has been uploaded.');
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
// Assert the untracked translation is shown.
$untracked = $this
->xpath("//a[contains(@class,'language-icon') and contains(@class, 'target-untracked') and contains(text(), 'ES')]");
$this
->assertEqual(count($untracked), 1, 'Untracked translation is shown.');
// And we can already request a translation.
$this
->assertLinkByHref($basepath . '/admin/lingotek/entity/add_target/dummy-document-hash-id/es_MX?destination=' . $basepath . '/admin/lingotek/manage/node');
$this
->clickLink('EN');
$this
->assertText('The import for node Llamas are cool is complete.');
// Request the Spanish translation.
$this
->assertLinkByHref($basepath . '/admin/lingotek/entity/add_target/dummy-document-hash-id/es_MX?destination=' . $basepath . '/admin/lingotek/manage/node');
$this
->clickLink('ES');
$this
->assertText("Locale 'es_MX' was added as a translation target for node Llamas are cool.");
$this
->assertIdentical('es_MX', \Drupal::state()
->get('lingotek.added_target_locale'));
// Check status of the Spanish translation.
$this
->assertLinkByHref($basepath . '/admin/lingotek/entity/check_target/dummy-document-hash-id/es_MX?destination=' . $basepath . '/admin/lingotek/manage/node');
$this
->clickLink('ES');
$this
->assertIdentical('es_MX', \Drupal::state()
->get('lingotek.checked_target_locale'));
$this
->assertText('The es_MX translation for node Llamas are cool is ready for download.');
// Download the Spanish translation.
$this
->assertLinkByHref($basepath . '/admin/lingotek/entity/download/dummy-document-hash-id/es_MX?destination=' . $basepath . '/admin/lingotek/manage/node');
$this
->clickLink('ES');
$this
->assertText('The translation of node Llamas are cool into es_MX has been downloaded.');
$this
->assertIdentical('es_MX', \Drupal::state()
->get('lingotek.downloaded_locale'));
// Now the link is to the workbench, and it opens in a new tab.
$this
->assertLinkByHref($basepath . '/admin/lingotek/workbench/dummy-document-hash-id/es_MX');
$workbench_link = $this
->xpath("//a[@href='{$basepath}/admin/lingotek/workbench/dummy-document-hash-id/es_MX' and @target='_blank']");
$this
->assertEqual(count($workbench_link), 1, 'Workbench links open in a new tab.');
}