public function LingotekSaveTargetDataTest::testRightNodeIsSavedIfThereIsNoRevisionInMetadata in Lingotek Translation 3.4.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::testRightNodeIsSavedIfThereIsNoRevisionInMetadata()
- 4.0.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::testRightNodeIsSavedIfThereIsNoRevisionInMetadata()
- 3.0.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::testRightNodeIsSavedIfThereIsNoRevisionInMetadata()
- 3.1.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::testRightNodeIsSavedIfThereIsNoRevisionInMetadata()
- 3.2.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::testRightNodeIsSavedIfThereIsNoRevisionInMetadata()
- 3.3.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::testRightNodeIsSavedIfThereIsNoRevisionInMetadata()
- 3.5.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::testRightNodeIsSavedIfThereIsNoRevisionInMetadata()
- 3.6.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::testRightNodeIsSavedIfThereIsNoRevisionInMetadata()
- 3.7.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::testRightNodeIsSavedIfThereIsNoRevisionInMetadata()
- 3.8.x tests/src/Functional/LingotekSaveTargetDataTest.php \Drupal\Tests\lingotek\Functional\LingotekSaveTargetDataTest::testRightNodeIsSavedIfThereIsNoRevisionInMetadata()
File
- tests/
src/ Functional/ LingotekSaveTargetDataTest.php, line 60
Class
- LingotekSaveTargetDataTest
- Tests the Lingotek content service saves data to entities correctly.
Namespace
Drupal\Tests\lingotek\FunctionalCode
public function testRightNodeIsSavedIfThereIsNoRevisionInMetadata() {
// Create a node.
/** @var \Drupal\node\NodeInterface $node */
$node1 = $this
->createNode([
'type' => 'article',
'title' => 'Node 1',
]);
$node1
->save();
$node2 = $this
->createNode([
'type' => 'article',
'title' => 'Node 2',
]);
$node2
->save();
/** @var \Drupal\lingotek\LingotekContentTranslationServiceInterface $translation_service */
$translation_service = \Drupal::service('lingotek.content_translation');
$es_data = [
'title' => [
0 => [
'value' => 'Nodo 2 ES',
],
],
'body' => [
0 => [
'value' => 'es body',
],
],
'_lingotek_metadata' => [
'_entity_type_id' => 'node',
'_entity_id' => 2,
],
];
$translation_service
->saveTargetData($node2, 'es', $es_data);
$nodeUntranslated = \Drupal::entityTypeManager()
->getStorage('node')
->load(1);
$this
->assertFalse($nodeUntranslated
->hasTranslation('es'));
$nodeTranslated = \Drupal::entityTypeManager()
->getStorage('node')
->load(2);
$this
->assertTrue($nodeTranslated
->hasTranslation('es'));
}