3 namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
5 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
6 use Drupal\node\Entity\Node;
9 * Upgrade taxonomy term node associations.
11 * @group migrate_drupal_6
13 class MigrateTermNodeTest extends MigrateDrupal6TestBase {
18 public static $modules = ['taxonomy', 'menu_ui'];
23 protected function setUp() {
25 $this->installSchema('node', ['node_access']);
26 $this->migrateContent();
27 $this->migrateTaxonomy();
31 * Tests the Drupal 6 term-node association to Drupal 8 migration.
33 public function testTermNode() {
34 // This is a base plugin id and we want to run all derivatives.
35 $this->executeMigrations(['d6_term_node']);
37 $this->container->get('entity.manager')
41 $nodes = Node::loadMultiple([1, 2]);
43 $this->assertSame(1, count($node->field_vocabulary_1_i_0_));
44 $this->assertSame('1', $node->field_vocabulary_1_i_0_[0]->target_id);
46 $this->assertSame(2, count($node->field_vocabulary_2_i_1_));
47 $this->assertSame('2', $node->field_vocabulary_2_i_1_[0]->target_id);
48 $this->assertSame('3', $node->field_vocabulary_2_i_1_[1]->target_id);
52 * Tests that term associations are ignored when they belong to nodes which
55 public function testSkipNonExistentNode() {
56 // Node 2 is migrated by d6_node__story, but we need to pretend that it
57 // failed, so record that in the map table.
58 $this->mockFailure('d6_node:story', ['nid' => 2, 'language' => 'en']);
60 // d6_term_node__2 should skip over node 2 (a.k.a. revision 3) because,
61 // according to the map table, it failed.
62 $migration = $this->getMigration('d6_term_node:2');
63 $this->executeMigration($migration);
64 $this->assertNull($migration->getIdMap()->lookupDestinationId(['vid' => 3])[0]);