function MigrateTermNodeComplete::testTermNode

Same name in other branches
  1. 8.9.x core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeComplete.php \Drupal\Tests\taxonomy\Kernel\Migrate\d6\MigrateTermNodeComplete::testTermNode()
  2. 10 core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeComplete.php \Drupal\Tests\taxonomy\Kernel\Migrate\d6\MigrateTermNodeComplete::testTermNode()
  3. 11.x core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeComplete.php \Drupal\Tests\taxonomy\Kernel\Migrate\d6\MigrateTermNodeComplete::testTermNode()

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

File

core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeComplete.php, line 50

Class

MigrateTermNodeComplete
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([
        1,
        2,
    ]);
    $nodes = Node::loadMultiple([
        1,
        2,
    ]);
    $node = $nodes[1];
    $this->assertCount(1, $node->field_vocabulary_1_i_0_);
    $this->assertSame('1', $node->field_vocabulary_1_i_0_[0]->target_id);
    $node = $nodes[2];
    $this->assertCount(2, $node->field_vocabulary_2_i_1_);
    $this->assertSame('2', $node->field_vocabulary_2_i_1_[0]->target_id);
    $this->assertSame('3', $node->field_vocabulary_2_i_1_[1]->target_id);
    // Tests the Drupal 6 term-node association to Drupal 8 node revisions.
    $this->executeMigrations([
        'd6_term_node_revision',
    ]);
    $node = \Drupal::entityTypeManager()->getStorage('node')
        ->loadRevision(2001);
    $this->assertCount(2, $node->field_vocabulary_3_i_2_);
    $this->assertSame('4', $node->field_vocabulary_3_i_2_[0]->target_id);
    $this->assertSame('5', $node->field_vocabulary_3_i_2_[1]->target_id);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.