You are here

public function LingotekNodeNestedParagraphsTranslationTest::testContentEntityMetadataIsIncluded in Lingotek Translation 3.6.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::testContentEntityMetadataIsIncluded()
  2. 4.0.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::testContentEntityMetadataIsIncluded()
  3. 3.0.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::testContentEntityMetadataIsIncluded()
  4. 3.1.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::testContentEntityMetadataIsIncluded()
  5. 3.2.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::testContentEntityMetadataIsIncluded()
  6. 3.3.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::testContentEntityMetadataIsIncluded()
  7. 3.4.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::testContentEntityMetadataIsIncluded()
  8. 3.5.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::testContentEntityMetadataIsIncluded()
  9. 3.7.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::testContentEntityMetadataIsIncluded()
  10. 3.8.x tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeNestedParagraphsTranslationTest::testContentEntityMetadataIsIncluded()

Tests that the metadata of the node and the embedded paragraphs is included.

File

tests/src/Functional/LingotekNodeNestedParagraphsTranslationTest.php, line 164

Class

LingotekNodeNestedParagraphsTranslationTest
Tests translating a node with multiple locales including nested paragraphs.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testContentEntityMetadataIsIncluded() {

  // Login as admin.
  $this
    ->drupalLogin($this->rootUser);

  // Add paragraphed content.
  $this
    ->drupalGet('node/add/paragraphed_nested_content');
  $this
    ->drupalPostForm(NULL, NULL, t('Add Image + Text'));
  $this
    ->drupalPostForm(NULL, NULL, t('Add Image + Text'));
  $edit = [];
  $edit['title[0][value]'] = 'Llamas are cool';
  $edit['langcode[0][value]'] = 'en';
  $edit['field_paragraph_container[0][subform][field_paragraphs_demo][0][subform][field_text_demo][0][value]'] = 'Llamas are very cool for the first time';
  $edit['field_paragraph_container[0][subform][field_paragraphs_demo][1][subform][field_text_demo][0][value]'] = 'Llamas are very cool for the second time';
  $this
    ->saveAndPublishNodeForm($edit, NULL);
  $this->node = Node::load(1);

  /** @var \Drupal\lingotek\LingotekContentTranslationServiceInterface $translation_service */
  $translation_service = \Drupal::service('lingotek.content_translation');
  $serialized_node = $translation_service
    ->getSourceData($this->node);
  $this
    ->verbose(var_export($serialized_node, TRUE));

  // Main node metadata is there.
  $this
    ->assertTrue(isset($serialized_node['_lingotek_metadata']), 'The Lingotek metadata is included in the extracted data.');
  $this
    ->assertEqual('node', $serialized_node['_lingotek_metadata']['_entity_type_id'], 'Entity type id is included as metadata.');
  $this
    ->assertEqual(1, $serialized_node['_lingotek_metadata']['_entity_id'], 'Entity id is included as metadata.');
  $this
    ->assertEqual(1, $serialized_node['_lingotek_metadata']['_entity_revision'], 'Entity revision id is included as metadata.');
}