public function LingotekNodeEmbeddingTagsTranslationTest::testNodeTranslationAfterDeletedReference in Lingotek Translation 8.2
Same name and namespace in other branches
- 4.0.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::testNodeTranslationAfterDeletedReference()
- 3.0.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::testNodeTranslationAfterDeletedReference()
- 3.1.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::testNodeTranslationAfterDeletedReference()
- 3.2.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::testNodeTranslationAfterDeletedReference()
- 3.3.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::testNodeTranslationAfterDeletedReference()
- 3.4.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::testNodeTranslationAfterDeletedReference()
- 3.5.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::testNodeTranslationAfterDeletedReference()
- 3.6.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::testNodeTranslationAfterDeletedReference()
- 3.7.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::testNodeTranslationAfterDeletedReference()
- 3.8.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::testNodeTranslationAfterDeletedReference()
Tests that previous tags are deleted when downloading a new translation.
File
- tests/
src/ Functional/ LingotekNodeEmbeddingTagsTranslationTest.php, line 382
Class
- LingotekNodeEmbeddingTagsTranslationTest
- Tests translating a node with multiple locales embedding another entity.
Namespace
Drupal\Tests\lingotek\FunctionalCode
public function testNodeTranslationAfterDeletedReference() {
$this
->testNodeTranslationWithADeletedReferenceInARevision();
// This is a hack for avoiding writing different lingotek endpoint mocks.
\Drupal::state()
->set('lingotek.uploaded_content_type', 'node+taxonomy_term_emptied+metadata');
// Now we create a new revision, and this is removing both field tag reference.
\Drupal::entityTypeManager()
->getStorage('node')
->resetCache();
$this->node = Node::load(1);
unset($this->node->field_tags[0]);
$this->node
->setNewRevision();
$this->node
->save();
// Check that we removed the tags correctly.
$this
->drupalGet('node/1');
$this
->assertNoText('Camelid');
$this
->assertNoText('Herbivorous');
// We go back to the translations.
$this
->clickLink('Translate');
// And we reupload it.
$this
->clickLink('Upload');
$this
->checkForMetaRefresh();
$this
->assertText('Uploaded 1 document to Lingotek.');
// Check that only the configured fields have been uploaded, including tags
// and image even if not set.
$data = json_decode(\Drupal::state()
->get('lingotek.uploaded_content', '[]'), TRUE);
$this
->assertUploadedDataFieldCount($data, 4);
$this
->assertTrue(isset($data['title'][0]['value']));
$this
->assertEqual(1, count($data['body'][0]));
$this
->assertTrue(isset($data['body'][0]['value']));
$this
->assertTrue(isset($data['field_image']));
$this
->assertTrue(isset($data['field_tags']));
// The tags are emptied.
$this
->assertEmpty($data['field_tags']);
// The image field is empty.
$this
->assertEmpty($data['field_image']);
// Check translation status.
$this
->clickLink('Check translation status');
$this
->assertText('The es_AR translation for node Llamas are cool is ready for download.');
// Download translation.
$this
->clickLink('Download completed translation');
$this
->assertText('The translation of node Llamas are cool into es_AR has been downloaded.');
// The content is translated and published.
$this
->clickLink('Las llamas son chulas');
$this
->assertText('Las llamas son chulas');
$this
->assertText('Las llamas son muy chulas');
// The tags have been removed from the content when re-downloading.
$this
->assertNoText('Camélido');
$this
->assertNoText('Hervíboro');
}