diff --git a/core/modules/file/migration_templates/d6_upload_entity_display.yml b/core/modules/file/migration_templates/d6_upload_entity_display.yml index b097c88af429efa581f348d1c7c1d4787aee5c37..576bb68c0e66232a5a25db3fd82f2e6c66164e81 100644 --- a/core/modules/file/migration_templates/d6_upload_entity_display.yml +++ b/core/modules/file/migration_templates/d6_upload_entity_display.yml @@ -14,7 +14,14 @@ source: settings: {} process: entity_type: 'constants/entity_type' - bundle: node_type + bundle: + - + plugin: migration_lookup + migration: d6_node_type + source: node_type + - + plugin: skip_on_empty + method: row view_mode: 'constants/view_mode' field_name: 'constants/name' type: 'constants/type' diff --git a/core/modules/file/migration_templates/d6_upload_entity_form_display.yml b/core/modules/file/migration_templates/d6_upload_entity_form_display.yml index 75436db76129e74180beb9b7c972d3673662dab9..055749a97ebca537574432aa1540c88310013576 100644 --- a/core/modules/file/migration_templates/d6_upload_entity_form_display.yml +++ b/core/modules/file/migration_templates/d6_upload_entity_form_display.yml @@ -15,7 +15,14 @@ source: progress_indicator: throbber process: entity_type: 'constants/entity_type' - bundle: node_type + bundle: + - + plugin: migration_lookup + migration: d6_node_type + source: node_type + - + plugin: skip_on_empty + method: row field_name: 'constants/name' form_mode: 'constants/form_mode' type: 'constants/type' diff --git a/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityDisplayTest.php b/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityDisplayTest.php index fc6cf455b84054af6df07d9b51f09e1fbb6d618b..200dc8617a334db7c48944d217ed3c0b27a86ccb 100644 --- a/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityDisplayTest.php +++ b/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityDisplayTest.php @@ -23,13 +23,14 @@ class MigrateUploadEntityDisplayTest extends MigrateDrupal6TestBase { protected function setUp() { parent::setUp(); $this->migrateFields(); - $this->executeMigration('d6_upload_entity_display'); } /** - * Tests the Drupal 6 upload settings to Drupal 8 entity display migration. + * Tests Drupal 6 upload settings to Drupal 8 entity display migration. */ public function testUploadEntityDisplay() { + $this->executeMigration('d6_upload_entity_display'); + $display = EntityViewDisplay::load('node.page.default'); $component = $display->getComponent('upload'); $this->assertIdentical('file_default', $component['type']); @@ -46,4 +47,23 @@ public function testUploadEntityDisplay() { $this->assertIdentical(['node', 'page', 'default', 'upload'], $this->getMigration('d6_upload_entity_display')->getIdMap()->lookupDestinationID(['page'])); } + /** + * Tests that entity displays are ignored appropriately. + * + * Entity displays should be ignored when they belong to node types which + * were not migrated. + */ + public function testSkipNonExistentNodeType() { + // The "story" node type is migrated by d6_node_type but we need to pretend + // that it didn't occur, so record that in the map table. + $this->mockFailure('d6_node_type', ['type' => 'story']); + + // d6_upload_entity_display should skip over the "story" node type config + // because, according to the map table, it didn't occur. + $migration = $this->getMigration('d6_upload_entity_display'); + + $this->executeMigration($migration); + $this->assertNull($migration->getIdMap()->lookupDestinationIds(['node_type' => 'story'])[0][0]); + } + } diff --git a/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityFormDisplayTest.php b/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityFormDisplayTest.php index 4055ffbb57dcad5f85c788829090c1d2ef8414e3..36e9f1da209cfd9c5cb8dd972bd5ed5f780ce332 100644 --- a/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityFormDisplayTest.php +++ b/core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityFormDisplayTest.php @@ -23,13 +23,14 @@ class MigrateUploadEntityFormDisplayTest extends MigrateDrupal6TestBase { protected function setUp() { parent::setUp(); $this->migrateFields(); - $this->executeMigration('d6_upload_entity_form_display'); } /** - * Tests the Drupal 6 upload settings to Drupal 8 entity form display migration. + * Tests Drupal 6 upload settings to Drupal 8 entity form display migration. */ public function testUploadEntityFormDisplay() { + $this->executeMigration('d6_upload_entity_form_display'); + $display = EntityFormDisplay::load('node.page.default'); $component = $display->getComponent('upload'); $this->assertIdentical('file_generic', $component['type']); @@ -46,4 +47,23 @@ public function testUploadEntityFormDisplay() { $this->assertIdentical(['node', 'page', 'default', 'upload'], $this->getMigration('d6_upload_entity_form_display')->getIdMap()->lookupDestinationID(['page'])); } + /** + * Tests that entity displays are ignored appropriately. + * + * Entity displays should be ignored when they belong to node types which + * were not migrated. + */ + public function testSkipNonExistentNodeType() { + // The "story" node type is migrated by d6_node_type but we need to pretend + // that it didn't occur, so record that in the map table. + $this->mockFailure('d6_node_type', ['type' => 'story']); + + // d6_upload_entity_form_display should skip over the "story" node type + // config because according to the map table, it didn't occur. + $migration = $this->getMigration('d6_upload_entity_form_display'); + + $this->executeMigration($migration); + $this->assertNull($migration->getIdMap()->lookupDestinationIds(['node_type' => 'story'])[0][0]); + } + } diff --git a/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_display.yml b/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_display.yml index 3c52a2fb04b10c3be4e8bbbb19b5606f41d74b91..8f154c3c8214f419550253aa81b5e384a887412d 100644 --- a/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_display.yml +++ b/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_display.yml @@ -15,7 +15,14 @@ process: entity_type: 'constants/entity_type' view_mode: 'constants/view_mode' options: 'constants/options' - bundle: type + bundle: + - + plugin: migration_lookup + migration: d6_node_type + source: type + - + plugin: skip_on_empty + method: row field_name: plugin: migration_lookup migration: d6_taxonomy_vocabulary diff --git a/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_form_display.yml b/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_form_display.yml index 160f68c34c03af12fc26f2b23eac96bfe9ac0a9a..4ac6d646bca500289aa79ae8d728563b82084a63 100644 --- a/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_form_display.yml +++ b/core/modules/taxonomy/migration_templates/d6_vocabulary_entity_form_display.yml @@ -19,7 +19,14 @@ process: 0: options_select 1: entity_reference_autocomplete_tags options/weight: 'constants/options/weight' - bundle: type + bundle: + - + plugin: migration_lookup + migration: d6_node_type + source: type + - + plugin: skip_on_empty + method: row field_name: plugin: migration_lookup migration: d6_taxonomy_vocabulary diff --git a/core/modules/taxonomy/migration_templates/d6_vocabulary_field_instance.yml b/core/modules/taxonomy/migration_templates/d6_vocabulary_field_instance.yml index a3afd9b9458bf0efb8ca3d53e653db95cc10d2a1..6fe5eed0175cb6d350c501aadd18bb22ad1e2d3e 100644 --- a/core/modules/taxonomy/migration_templates/d6_vocabulary_field_instance.yml +++ b/core/modules/taxonomy/migration_templates/d6_vocabulary_field_instance.yml @@ -10,7 +10,14 @@ source: selection_handler: 'default:taxonomy_term' process: entity_type: 'constants/entity_type' - bundle: type + bundle: + - + plugin: migration_lookup + migration: d6_node_type + source: type + - + plugin: skip_on_empty + method: row field_name: - plugin: migration_lookup diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php index a0f261e0d50afc8c6c68d98170ce5f393c082f3e..f6fb85d74aea8ed1dd2f234af25eef617b8aecd3 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php @@ -22,13 +22,24 @@ class MigrateVocabularyEntityDisplayTest extends MigrateDrupal6TestBase { */ protected function setUp() { parent::setUp(); - $this->migrateTaxonomy(); + + // Execute Dependency Migrations. + $this->migrateContentTypes(); + $this->installEntitySchema('taxonomy_term'); + $this->executeMigrations([ + 'd6_node_type', + 'd6_taxonomy_vocabulary', + 'd6_vocabulary_field', + 'd6_vocabulary_field_instance', + ]); } /** * Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration. */ public function testVocabularyEntityDisplay() { + $this->executeMigration('d6_vocabulary_entity_display'); + // Test that the field exists. $component = EntityViewDisplay::load('node.page.default')->getComponent('tags'); $this->assertIdentical('entity_reference_label', $component['type']); @@ -37,4 +48,23 @@ public function testVocabularyEntityDisplay() { $this->assertIdentical(['node', 'article', 'default', 'tags'], $this->getMigration('d6_vocabulary_entity_display')->getIdMap()->lookupDestinationID([4, 'article'])); } + /** + * Tests that vocabulary displays are ignored appropriately. + * + * Vocabulary displays should be ignored when they belong to node types which + * were not migrated. + */ + public function testSkipNonExistentNodeType() { + // The "story" node type is migrated by d6_node_type but we need to pretend + // that it didn't occur, so record that in the map table. + $this->mockFailure('d6_node_type', ['type' => 'story']); + + // d6_vocabulary_entity_display should skip over the "story" node type + // config because, according to the map table, it didn't occur. + $migration = $this->getMigration('d6_vocabulary_entity_display'); + + $this->executeMigration($migration); + $this->assertNull($migration->getIdMap()->lookupDestinationIds(['type' => 'story'])[0][0]); + } + } diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php index 417105c54e119052f82d60862fa0fa4fddb4dbbe..93ac64369fac60af09867efe81b1f07133a05757 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php @@ -22,13 +22,24 @@ class MigrateVocabularyEntityFormDisplayTest extends MigrateDrupal6TestBase { */ protected function setUp() { parent::setUp(); - $this->migrateTaxonomy(); + + // Execute Dependency Migrations. + $this->migrateContentTypes(); + $this->installEntitySchema('taxonomy_term'); + $this->executeMigrations([ + 'd6_taxonomy_vocabulary', + 'd6_vocabulary_field', + 'd6_vocabulary_field_instance', + 'd6_vocabulary_entity_display', + ]); } /** * Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration. */ public function testVocabularyEntityFormDisplay() { + $this->executeMigration('d6_vocabulary_entity_form_display'); + // Test that the field exists. $component = EntityFormDisplay::load('node.page.default')->getComponent('tags'); $this->assertIdentical('options_select', $component['type']); @@ -42,4 +53,23 @@ public function testVocabularyEntityFormDisplay() { $this->assertIdentical($entity_form_display->getComponent('vocabulary_2_i_1_')['type'], 'entity_reference_autocomplete_tags'); } + /** + * Tests that vocabulary displays are ignored appropriately. + * + * Vocabulary displays should be ignored when they belong to node types which + * were not migrated. + */ + public function testSkipNonExistentNodeType() { + // The "story" node type is migrated by d6_node_type but we need to pretend + // that it didn't occur, so record that in the map table. + $this->mockFailure('d6_node_type', ['type' => 'story']); + + // d6_vocabulary_entity_form_display should skip over the "story" node type + // config because, according to the map table, it didn't occur. + $migration = $this->getMigration('d6_vocabulary_entity_form_display'); + + $this->executeMigration($migration); + $this->assertNull($migration->getIdMap()->lookupDestinationIds(['type' => 'story'])[0][0]); + } + } diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php index 9264260ebfbbe24418c9f7cda05ae009f22070ec..bd5a497dd7f260a1e954c01e67d63c11ab1c490b 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php @@ -22,13 +22,23 @@ class MigrateVocabularyFieldInstanceTest extends MigrateDrupal6TestBase { */ protected function setUp() { parent::setUp(); - $this->migrateTaxonomy(); + + // Execute Dependency Migrations. + $this->migrateContentTypes(); + $this->installEntitySchema('taxonomy_term'); + $this->executeMigrations([ + 'd6_node_type', + 'd6_taxonomy_vocabulary', + 'd6_vocabulary_field', + ]); } /** * Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration. */ public function testVocabularyFieldInstance() { + $this->executeMigration('d6_vocabulary_field_instance'); + // Test that the field exists. $field_id = 'node.article.tags'; $field = FieldConfig::load($field_id); @@ -50,10 +60,29 @@ public function testVocabularyFieldInstance() { $this->assertIdentical(['node', 'article', 'tags'], $this->getMigration('d6_vocabulary_field_instance')->getIdMap()->lookupDestinationID([4, 'article'])); - // Test the the field vocabulary_1_i_0_ + // Test the the field vocabulary_1_i_0_. $field_id = 'node.story.vocabulary_1_i_0_'; $field = FieldConfig::load($field_id); $this->assertFalse($field->isRequired(), 'Field is not required'); } + /** + * Tests that vocabulary field instances are ignored appropriately. + * + * Vocabulary field instances should be ignored when they belong to node + * types which were not migrated. + */ + public function testSkipNonExistentNodeType() { + // The "story" node type is migrated by d6_node_type but we need to pretend + // that it didn't occur, so record that in the map table. + $this->mockFailure('d6_node_type', ['type' => 'story']); + + // d6_vocabulary_field_instance should skip over the "story" node type + // config because, according to the map table, it didn't occur. + $migration = $this->getMigration('d6_vocabulary_field_instance'); + + $this->executeMigration($migration); + $this->assertNull($migration->getIdMap()->lookupDestinationIds(['type' => 'story'])[0][0]); + } + }