public function LingotekNodeMissingProfileTranslationTest::testNodeTranslationUsingLinks in Lingotek Translation 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/LingotekNodeMissingProfileTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMissingProfileTranslationTest::testNodeTranslationUsingLinks()
- 4.0.x tests/src/Functional/LingotekNodeMissingProfileTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMissingProfileTranslationTest::testNodeTranslationUsingLinks()
- 3.1.x tests/src/Functional/LingotekNodeMissingProfileTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMissingProfileTranslationTest::testNodeTranslationUsingLinks()
- 3.2.x tests/src/Functional/LingotekNodeMissingProfileTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMissingProfileTranslationTest::testNodeTranslationUsingLinks()
- 3.3.x tests/src/Functional/LingotekNodeMissingProfileTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMissingProfileTranslationTest::testNodeTranslationUsingLinks()
- 3.4.x tests/src/Functional/LingotekNodeMissingProfileTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMissingProfileTranslationTest::testNodeTranslationUsingLinks()
- 3.5.x tests/src/Functional/LingotekNodeMissingProfileTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMissingProfileTranslationTest::testNodeTranslationUsingLinks()
- 3.6.x tests/src/Functional/LingotekNodeMissingProfileTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMissingProfileTranslationTest::testNodeTranslationUsingLinks()
- 3.7.x tests/src/Functional/LingotekNodeMissingProfileTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMissingProfileTranslationTest::testNodeTranslationUsingLinks()
- 3.8.x tests/src/Functional/LingotekNodeMissingProfileTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeMissingProfileTranslationTest::testNodeTranslationUsingLinks()
Tests that a node can be translated using the links on the management page.
File
- tests/
src/ Functional/ LingotekNodeMissingProfileTranslationTest.php, line 66
Class
- LingotekNodeMissingProfileTranslationTest
- Tests translating a node with images 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';
$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_MX');
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool has been uploaded.');
// Check that only the configured fields have been uploaded.
$data = json_decode(\Drupal::state()
->get('lingotek.uploaded_content', '[]'), TRUE);
$this
->assertUploadedDataFieldCount($data, 2);
$this
->assertTrue(isset($data['title'][0]['value']));
$this
->assertEqual(1, count($data['body'][0]));
$this
->assertTrue(isset($data['body'][0]['value']));
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
// There is a link for checking status.
$this
->assertLingotekCheckSourceStatusLink();
// And we can already request a translation.
$this
->assertLingotekRequestTranslationLink('es_MX');
$this
->clickLink('EN');
$this
->assertText('The import for node Llamas are cool is complete.');
// Request the Spanish translation.
$this
->assertLingotekRequestTranslationLink('es_MX');
$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
->assertLingotekCheckTargetStatusLink('es_MX');
$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
->assertLingotekDownloadTargetLink('es_MX');
$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
->assertLingotekWorkbenchLink('es_MX');
$profile = LingotekProfile::load('missing_profile');
$profile
->delete();
$this
->drupalGet('node/1/edit');
$edit = [];
$edit['title[0][value]'] = 'Cats are cool';
$this
->saveAndPublishNodeForm($edit, NULL);
// No errors on saving even if the profile was missing.
$this
->assertText('Article Cats are cool has been updated.');
// Automatic profile wasn't being used automatically.
$this
->assertNoText('Cats are cool was updated and sent to Lingotek successfully.');
}