public function LingotekNodeTranslationFlowNotCurrentToPendingTest::testNodeTargetStatusAfterSourceEditAndUpload in Lingotek Translation 8
Tests that a node can be translated.
File
- src/
Tests/ LingotekNodeTranslationFlowNotCurrentToPendingTest.php, line 65
Class
- LingotekNodeTranslationFlowNotCurrentToPendingTest
- Tests translating a node.
Namespace
Drupal\lingotek\TestsCode
public function testNodeTargetStatusAfterSourceEditAndUpload() {
// Login as admin.
$this
->drupalLogin($this->rootUser);
// Create a node.
$edit = array();
$edit['title[0][value]'] = 'Llamas are cool';
$edit['body[0][value]'] = 'Llamas are very cool';
$edit['langcode[0][value]'] = 'en';
$edit['lingotek_translation_profile'] = 'manual';
$this
->drupalPostForm('node/add/article', $edit, t('Save and publish'));
$this
->goToContentBulkManagementForm();
$basepath = \Drupal::request()
->getBasePath();
// 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
->assertNoLinkByHref($basepath . '/admin/lingotek/entity/add_target/dummy-document-hash-id/de_AT?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'));
// There is a link for checking status.
$this
->assertLinkByHref($basepath . '/admin/lingotek/entity/check_upload/dummy-document-hash-id?destination=' . $basepath . '/admin/lingotek/manage/node');
// 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
->assertLinkByHref($basepath . '/admin/lingotek/entity/add_target/dummy-document-hash-id/de_AT?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'));
// Edit the Source
$edit = array();
$edit['title[0][value]'] = 'Llamas are cool EDITED';
$this
->drupalPostForm('node/1/edit', $edit, t('Save and keep published (this translation)'));
$this
->goToContentBulkManagementForm();
// Check the status is marked NOT_CURRENT for Spanish
$es_edited = $this
->xpath("//a[contains(@class,'language-icon') and contains(@class, 'target-edited') and contains(text(), 'ES')]");
$this
->assertEqual(count($es_edited), 1, 'Spanish is marked as not current.');
// Check the status is marked REQUEST for German
$de_request = $this
->xpath("//a[contains(@class,'language-icon') and contains(@class, 'target-request') and contains(text(), 'DE')]");
$this
->assertEqual(count($de_request), 1, 'German is marked as request.');
// Clicking English must init the upload of content.
$this
->assertLinkByHref($basepath . '/admin/lingotek/entity/update/dummy-document-hash-id?destination=' . $basepath . '/admin/lingotek/manage/node');
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool EDITED has been updated.');
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
// There is a link for checking status.
$this
->assertLinkByHref($basepath . '/admin/lingotek/entity/check_upload/dummy-document-hash-id?destination=' . $basepath . '/admin/lingotek/manage/node');
$this
->clickLink('EN');
$this
->assertText('The import for node Llamas are cool EDITED is complete.');
$es_pending = $this
->xpath("//a[contains(@class,'language-icon') and contains(@class, 'target-pending') and contains(text(), 'ES')]");
$this
->assertEqual(count($es_pending), 1, 'Spanish is marked as pending.');
// Check the status is still request for German.
$de_request = $this
->xpath("//a[contains(@class,'language-icon') and contains(@class, 'target-request') and contains(text(), 'DE')]");
$this
->assertEqual(count($de_request), 1, 'German is still marked as request.');
}