3 namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
5 use Drupal\Core\Entity\Entity\EntityViewDisplay;
6 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
9 * Vocabulary entity display migration.
11 * @group migrate_drupal_6
13 class MigrateVocabularyEntityDisplayTest extends MigrateDrupal6TestBase {
18 public static $modules = ['field', 'taxonomy', 'menu_ui'];
23 protected function setUp() {
26 // Execute Dependency Migrations.
27 $this->migrateContentTypes();
28 $this->installEntitySchema('taxonomy_term');
29 $this->executeMigrations([
31 'd6_taxonomy_vocabulary',
32 'd6_vocabulary_field',
33 'd6_vocabulary_field_instance',
38 * Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
40 public function testVocabularyEntityDisplay() {
41 $this->executeMigration('d6_vocabulary_entity_display');
43 // Test that the field exists.
44 $component = EntityViewDisplay::load('node.page.default')->getComponent('field_tags');
45 $this->assertSame('entity_reference_label', $component['type']);
46 $this->assertSame(20, $component['weight']);
48 $this->assertSame(['node', 'article', 'default', 'field_tags'], $this->getMigration('d6_vocabulary_entity_display')->getIdMap()->lookupDestinationID([4, 'article']));
50 // Tests that a vocabulary named like a D8 base field will be migrated and
51 // prefixed with 'field_' to avoid conflicts.
52 $field_type = EntityViewDisplay::load('node.sponsor.default')->getComponent('field_type');
53 $this->assertTrue(is_array($field_type));
57 * Tests that vocabulary displays are ignored appropriately.
59 * Vocabulary displays should be ignored when they belong to node types which
62 public function testSkipNonExistentNodeType() {
63 // The "story" node type is migrated by d6_node_type but we need to pretend
64 // that it didn't occur, so record that in the map table.
65 $this->mockFailure('d6_node_type', ['type' => 'story']);
67 // d6_vocabulary_entity_display should skip over the "story" node type
68 // config because, according to the map table, it didn't occur.
69 $migration = $this->getMigration('d6_vocabulary_entity_display');
71 $this->executeMigration($migration);
72 $this->assertNull($migration->getIdMap()->lookupDestinationIds(['type' => 'story'])[0][0]);