public function LingotekContentModerationTest::testBulkManagementUploadsLatestDraftRevision 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::testBulkManagementUploadsLatestDraftRevision()
- 3.7.x tests/src/Functional/LingotekContentModerationTest.php \Drupal\Tests\lingotek\Functional\LingotekContentModerationTest::testBulkManagementUploadsLatestDraftRevision()
File
- tests/
src/ Functional/ LingotekContentModerationTest.php, line 668
Class
- LingotekContentModerationTest
- Tests setting up the integration with content moderation.
Namespace
Drupal\Tests\lingotek\FunctionalCode
public function testBulkManagementUploadsLatestDraftRevision() {
// This is a hack for avoiding writing different lingotek endpoint mocks.
\Drupal::state()
->set('lingotek.uploaded_content_type', 'nodeedited+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.');
// 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.');
$this
->goToContentBulkManagementForm();
// Upload.
$this
->clickLink('EN');
$this
->assertText('Node Llamas are cool has been uploaded.');
// Check that only the last revision fields have been uploaded.
$data = json_decode(\Drupal::state()
->get('lingotek.uploaded_content', '[]'), TRUE);
$this
->assertUploadedDataFieldCount($data, 2);
$this
->assertEquals('Dogs are cool', $data['title'][0]['value']);
$this
->assertEquals(1, count($data['body'][0]));
$this
->assertEquals('Dogs are very cool', $data['body'][0]['value']);
$this
->assertSame('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
}