public function LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithGeneralSettings in Lingotek Translation 3.3.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithGeneralSettings()
- 4.0.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithGeneralSettings()
- 3.0.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithGeneralSettings()
- 3.1.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithGeneralSettings()
- 3.2.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithGeneralSettings()
- 3.4.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithGeneralSettings()
- 3.5.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithGeneralSettings()
- 3.6.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithGeneralSettings()
- 3.7.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithGeneralSettings()
- 3.8.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithGeneralSettings()
Tests that a node can be translated.
File
- tests/
src/ Functional/ LingotekIntelligenceMetadataTranslationTest.php, line 202
Class
- LingotekIntelligenceMetadataTranslationTest
- Tests if intelligence metadata is used when uploading and updating content.
Namespace
Drupal\Tests\lingotek\FunctionalCode
public function testUploadNodeWithGeneralSettings() {
$domain = \Drupal::request()
->getSchemeAndHttpHost();
$this
->setupGeneralIntelligenceSettings();
$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);
$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'], '1');
$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'], 'admin@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');
}