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