You are here

public function LingotekIntelligenceMetadataTranslationTest::testUpdateNodeWithNoSettings in Lingotek Translation 3.6.x

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

File

tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php, line 397

Class

LingotekIntelligenceMetadataTranslationTest
Tests if intelligence metadata is used when uploading and updating content.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testUpdateNodeWithNoSettings() {
  $this
    ->disableIntelligenceMetadata();
  $this
    ->drupalLogin($this->rootUser);

  // Create a node.
  $edit = [];
  $edit['title[0][value]'] = 'Llamas are cool';
  $edit['body[0][value]'] = 'Llamas are very cool';
  $edit['langcode[0][value]'] = 'en';
  $this
    ->saveAndPublishNodeForm($edit);
  $edit['body[0][value]'] = 'Llamas are still very cool';
  $this
    ->saveAndKeepPublishedNodeForm($edit, 1);
  $this->node = Node::load(1);

  // Check that the translate tab is in the node.
  $this
    ->drupalGet('node/1');
  $this
    ->clickLink('Translate');

  // Check that only the configured fields have been uploaded.
  $data = json_decode(\Drupal::state()
    ->get('lingotek.uploaded_content', '[]'), TRUE);
  $this
    ->assertUploadedDataFieldCount($data, 3);
  $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['uid']));
  $this
    ->assertFalse(isset($data['uid'][0]['_lingotek_metadata']['_intelligence']));
  $this
    ->assertIdentical($data['uid'][0]['_lingotek_metadata']['_entity_id'], '1');
  $this
    ->assertIdentical($data['uid'][0]['_lingotek_metadata']['_entity_type_id'], 'user');
  $this
    ->assertNull($data['uid'][0]['_lingotek_metadata']['_entity_revision']);
  $this
    ->assertIdentical('en_US', \Drupal::state()
    ->get('lingotek.uploaded_locale'));

  // Check that the profile used was the right one.
  $used_profile = \Drupal::state()
    ->get('lingotek.used_profile');
  $this
    ->assertIdentical('automatic', $used_profile, 'The automatic profile was used.');
  $this
    ->assertEqual(4, count($data['_lingotek_metadata']));
  $this
    ->assertIdentical($data['_lingotek_metadata']['_entity_id'], '1');
  $this
    ->assertIdentical($data['_lingotek_metadata']['_entity_revision'], '2');
  $this
    ->assertIdentical($data['_lingotek_metadata']['_entity_type_id'], 'node');
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['external_document_id'], '1');
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['content_type'], 'node - article');
}