You are here

public function LingotekIntelligenceMetadataTranslationTest::testUpdateNodeWithContactEmailAsAuthorSetting 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::testUpdateNodeWithContactEmailAsAuthorSetting()
  2. 4.0.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUpdateNodeWithContactEmailAsAuthorSetting()
  3. 3.0.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUpdateNodeWithContactEmailAsAuthorSetting()
  4. 3.1.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUpdateNodeWithContactEmailAsAuthorSetting()
  5. 3.2.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUpdateNodeWithContactEmailAsAuthorSetting()
  6. 3.3.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUpdateNodeWithContactEmailAsAuthorSetting()
  7. 3.4.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUpdateNodeWithContactEmailAsAuthorSetting()
  8. 3.5.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUpdateNodeWithContactEmailAsAuthorSetting()
  9. 3.7.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUpdateNodeWithContactEmailAsAuthorSetting()
  10. 3.8.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUpdateNodeWithContactEmailAsAuthorSetting()

File

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

Class

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

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testUpdateNodeWithContactEmailAsAuthorSetting() {
  $domain = \Drupal::request()
    ->getSchemeAndHttpHost();

  // 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);
  $this
    ->setupGeneralIntelligenceSettings();
  $this
    ->setupContactEmailForAuthorIntelligenceSettings();
  $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
    ->assertEqual(17, count($data['_lingotek_metadata']['_intelligence']));
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['external_document_id'], '1');
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['content_type'], 'node - article');
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['domain'], $domain);
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['reference_url'], $this->node
    ->toUrl()
    ->setAbsolute(TRUE)
    ->toString());
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['author_name'], 'admin');
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['author_email'], 'general@example.com');
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['business_unit'], 'General Business Unit');
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['business_division'], 'General Business Division');
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['campaign_id'], 'General Campaign ID');
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['campaign_rating'], 3);
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['channel'], 'General Channel Test');
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['contact_name'], 'General Test Contact Name');
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['contact_email'], 'general@example.com');
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['content_description'], 'General Content description');
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['external_style_id'], 'general-my-style-id');
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['purchase_order'], 'General PO32');
  $this
    ->assertIdentical($data['_lingotek_metadata']['_intelligence']['region'], 'region2');
}