public function LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithNoSettings in Lingotek Translation 3.6.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithNoSettings()
- 4.0.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithNoSettings()
- 3.0.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithNoSettings()
- 3.1.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithNoSettings()
- 3.2.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithNoSettings()
- 3.3.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithNoSettings()
- 3.4.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithNoSettings()
- 3.5.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithNoSettings()
- 3.7.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithNoSettings()
- 3.8.x tests/src/Functional/LingotekIntelligenceMetadataTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekIntelligenceMetadataTranslationTest::testUploadNodeWithNoSettings()
Tests that a node can be translated.
File
- tests/
src/ Functional/ LingotekIntelligenceMetadataTranslationTest.php, line 90
Class
- LingotekIntelligenceMetadataTranslationTest
- Tests if intelligence metadata is used when uploading and updating content.
Namespace
Drupal\Tests\lingotek\FunctionalCode
public function testUploadNodeWithNoSettings() {
$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);
$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
->assertIdentical($data['_lingotek_metadata']['_intelligence']['external_document_id'], '1');
$this
->assertIdentical($data['_lingotek_metadata']['_intelligence']['content_type'], 'node - article');
}