MigrateTermNodeTest.php in Drupal 9
File
core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeTest.php
View source
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
use Drupal\node\Entity\Node;
class MigrateTermNodeTest extends MigrateDrupal6TestBase {
protected static $modules = [
'taxonomy',
'menu_ui',
];
protected function setUp() : void {
parent::setUp();
$this
->installSchema('node', [
'node_access',
]);
$this
->migrateContent();
$this
->migrateTaxonomy();
}
public function testTermNode() {
$this
->executeMigrations([
'd6_term_node',
]);
$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);
}
public function testSkipNonExistentNode() {
$this
->mockFailure('d6_node:story', [
'nid' => 2,
'language' => 'en',
]);
$migration = $this
->getMigration('d6_term_node:2');
$this
->executeMigration($migration);
$this
->assertNull($migration
->getIdMap()
->lookupDestinationIds([
'vid' => 3,
])[0][0]);
}
}