public function LingotekContentModerationTest::testPublishedRevisionDownloadDoesntOverwriteDraftNonDefaultRevision in Lingotek Translation 3.8.x
Same name and namespace in other branches
- 4.0.x tests/src/Functional/LingotekContentModerationTest.php \Drupal\Tests\lingotek\Functional\LingotekContentModerationTest::testPublishedRevisionDownloadDoesntOverwriteDraftNonDefaultRevision()
- 3.7.x tests/src/Functional/LingotekContentModerationTest.php \Drupal\Tests\lingotek\Functional\LingotekContentModerationTest::testPublishedRevisionDownloadDoesntOverwriteDraftNonDefaultRevision()
File
- tests/
src/ Functional/ LingotekContentModerationTest.php, line 458
Class
- LingotekContentModerationTest
- Tests setting up the integration with content moderation.
Namespace
Drupal\Tests\lingotek\FunctionalCode
public function testPublishedRevisionDownloadDoesntOverwriteDraftNonDefaultRevision() {
// This is a hack for avoiding writing different lingotek endpoint mocks.
\Drupal::state()
->set('lingotek.uploaded_content_type', 'nodesource+revision');
$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, 'article');
$this
->assertText('Article Llamas are cool has been created.');
$this
->goToContentBulkManagementForm();
// Upload.
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool has been uploaded.');
// Request translation.
$this
->clickLink('ES');
$this
->assertText('Locale \'es_MX\' was added as a translation target for node Llamas are cool.');
// Check translation.
$this
->clickLink('ES');
$this
->assertText('The es_MX translation for node Llamas are cool is ready for download.');
// Edit the original as a new draft.
$edit = [];
$edit['title[0][value]'] = 'Dogs are cool';
$edit['body[0][value]'] = 'Dogs are very cool';
$this
->editAsNewDraftNodeForm('/node/1/edit', $edit);
$this
->assertNoText('Dogs are cool was updated and sent to Lingotek successfully.');
$this
->assertText('Article Dogs are cool has been updated.');
// The source published revision is the default one.
$this
->drupalGet('node/1');
$this
->assertText('Llamas are cool');
$this
->goToContentBulkManagementForm();
// Download translation.
$edit = [
'table[1]' => TRUE,
'operation' => 'download:es',
];
$this
->drupalPostForm(NULL, $edit, t('Execute'));
$this
->assertText('Operations completed.');
// The source published revision must be the same still.
$this
->drupalGet('node/1');
$this
->assertText('Llamas are cool');
// But the latest revision should keep the unpublished revision content.
$this
->drupalGet('node/1/latest');
$this
->assertText('Dogs are cool');
// The published revision for the translated content is the right one.
$this
->drupalGet('es/node/1');
$this
->assertText('Las llamas son chulas');
// There's only one revision for Spanish so we cannot check the latest.
}