class MigrateTermNodeComplete
Upgrade taxonomy term node associations.
@group migrate_drupal_6
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\migrate\Kernel\MigrateTestBase extends \Drupal\migrate\MigrateMessageInterface implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase implements \Drupal\Tests\migrate\Kernel\MigrateTestBase
- class \Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase uses \Drupal\Tests\migrate_drupal\Traits\NodeMigrateTypeTestTrait implements \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase
- class \Drupal\Tests\taxonomy\Kernel\Migrate\d6\MigrateTermNodeComplete implements \Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase
- class \Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase uses \Drupal\Tests\migrate_drupal\Traits\NodeMigrateTypeTestTrait implements \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase
- class \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase implements \Drupal\Tests\migrate\Kernel\MigrateTestBase
- class \Drupal\Tests\migrate\Kernel\MigrateTestBase extends \Drupal\migrate\MigrateMessageInterface implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of MigrateTermNodeComplete
File
-
core/
modules/ taxonomy/ tests/ src/ Kernel/ Migrate/ d6/ MigrateTermNodeComplete.php, line 14
Namespace
Drupal\Tests\taxonomy\Kernel\Migrate\d6View source
class MigrateTermNodeComplete extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'content_translation',
'language',
'menu_ui',
'taxonomy',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
// Remove the classic node table made in setup.
$this->removeNodeMigrateMapTable(NodeMigrateType::NODE_MIGRATE_TYPE_CLASSIC, '6');
$this->installSchema('node', [
'node_access',
]);
$this->installEntitySchema('node');
$this->executeMigration('language');
$this->migrateUsers(FALSE);
$this->migrateFields();
$this->executeMigrations([
'd6_node_settings',
'd6_node_complete',
]);
$this->migrateTaxonomy();
// This is a base plugin ID and we want to run all derivatives.
$this->executeMigrations([
'd6_term_node',
]);
}
/**
* Tests the Drupal 6 term-node association to Drupal 8 migration.
*/
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.