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('tags');
45 $this->assertIdentical('options_select', $component['type']);
46 $this->assertIdentical(20, $component['weight']);
48 $this->assertIdentical(['node', 'article', 'default', '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->assertIdentical($entity_form_display->getComponent('vocabulary_1_i_0_')['type'], 'options_select');
53 $this->assertIdentical($entity_form_display->getComponent('vocabulary_2_i_1_')['type'], 'entity_reference_autocomplete_tags');
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_form_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_form_display');
71 $this->executeMigration($migration);
72 $this->assertNull($migration->getIdMap()->lookupDestinationIds(['type' => 'story'])[0][0]);