You are here

public function LingotekGetSourceDataTest::testContentEntityMetadataIsIncluded in Lingotek Translation 3.3.x

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

File

tests/src/Functional/LingotekGetSourceDataTest.php, line 90

Class

LingotekGetSourceDataTest
Tests the Lingotek content service extract data from entities correctly.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testContentEntityMetadataIsIncluded() {

  // Create a node.
  $node = $this
    ->createNode([
    'type' => 'article',
  ]);

  /** @var \Drupal\lingotek\LingotekContentTranslationServiceInterface $translation_service */
  $translation_service = \Drupal::service('lingotek.content_translation');
  $serialized_node = $translation_service
    ->getSourceData($node);
  $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.');
  $node
    ->setNewRevision();
  $node
    ->setTitle($this
    ->randomString(10));
  $node
    ->save();
  $serialized_node = $translation_service
    ->getSourceData($node);
  $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(2, $serialized_node['_lingotek_metadata']['_entity_revision'], 'Entity revision id is included as metadata, and has changed.');
}