You are here

public function MigrateTermNodeTranslationTest::testTermNode in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeTranslationTest.php \Drupal\Tests\taxonomy\Kernel\Migrate\d6\MigrateTermNodeTranslationTest::testTermNode()

Tests the Drupal 6 term-node association to Drupal 8 migration.

File

core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeTranslationTest.php, line 55

Class

MigrateTermNodeTranslationTest
Upgrade taxonomy term node associations.

Namespace

Drupal\Tests\taxonomy\Kernel\Migrate\d6

Code

public function testTermNode() {
  $this->container
    ->get('entity_type.manager')
    ->getStorage('node')
    ->resetCache([
    18,
    21,
  ]);

  // Test with translated content type employee. Vocabulary
  // field_vocabulary_name_much_longe is a localized vocabulary and
  // field_vocabulary_3_i_2_ is a per language vocabulary.
  // An untranslated node.
  $node = Node::load(18);

  // A localized vocabulary.
  $this
    ->assertSame('15', $node->field_vocabulary_name_much_longe[0]->target_id);

  // Per language vocabulary.
  $this
    ->assertSame('5', $node->field_vocabulary_3_i_2_[0]->target_id);

  // A translated node.
  // The English node.
  $node = Node::load(21);
  $this
    ->assertSame('15', $node->field_vocabulary_name_much_longe[0]->target_id);
  $this
    ->assertSame('4', $node->field_vocabulary_3_i_2_[0]->target_id);

  // The French translation of the English node.
  $translation = $node
    ->getTranslation('fr');
  $this
    ->assertSame('14', $translation->field_vocabulary_name_much_longe[0]->target_id);
  $this
    ->assertSame('9', $translation->field_vocabulary_3_i_2_[0]->target_id);
}