diff --git a/core/modules/ban/src/Plugin/migrate/destination/BlockedIp.php b/core/modules/ban/src/Plugin/migrate/destination/BlockedIp.php index 7c570bb793..19f66723e6 100644 --- a/core/modules/ban/src/Plugin/migrate/destination/BlockedIp.php +++ b/core/modules/ban/src/Plugin/migrate/destination/BlockedIp.php @@ -13,7 +13,8 @@ * Destination for blocked IP addresses. * * @MigrateDestination( - * id = "blocked_ip" + * id = "blocked_ip", + * destination_module = "ban", * ) */ class BlockedIP extends DestinationBase implements ContainerFactoryPluginInterface { diff --git a/core/modules/block/src/Plugin/migrate/destination/EntityBlock.php b/core/modules/block/src/Plugin/migrate/destination/EntityBlock.php index 537b16073e..2a2a4fb1eb 100644 --- a/core/modules/block/src/Plugin/migrate/destination/EntityBlock.php +++ b/core/modules/block/src/Plugin/migrate/destination/EntityBlock.php @@ -7,7 +7,8 @@ /** * @MigrateDestination( - * id = "entity:block" + * id = "entity:block", + * destination_module = "block", * ) */ class EntityBlock extends EntityConfigBase { diff --git a/core/modules/book/src/Plugin/migrate/destination/Book.php b/core/modules/book/src/Plugin/migrate/destination/Book.php index 3659b34f4f..cd5383e414 100644 --- a/core/modules/book/src/Plugin/migrate/destination/Book.php +++ b/core/modules/book/src/Plugin/migrate/destination/Book.php @@ -9,7 +9,8 @@ /** * @MigrateDestination( * id = "book", - * provider = "book" + * provider = "book", + * destination_module = "book", * ) */ class Book extends EntityContentBase { diff --git a/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php b/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php index efce666a77..9e140ba3a2 100644 --- a/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php +++ b/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php @@ -13,7 +13,8 @@ /** * @MigrateDestination( - * id = "entity:comment" + * id = "entity:comment", + * destination_module = "comment", * ) */ class EntityComment extends EntityContentBase { diff --git a/core/modules/comment/src/Plugin/migrate/destination/EntityCommentType.php b/core/modules/comment/src/Plugin/migrate/destination/EntityCommentType.php index 9bee87a3a1..23a649ea94 100644 --- a/core/modules/comment/src/Plugin/migrate/destination/EntityCommentType.php +++ b/core/modules/comment/src/Plugin/migrate/destination/EntityCommentType.php @@ -7,7 +7,8 @@ /** * @MigrateDestination( - * id = "entity:comment_type" + * id = "entity:comment_type", + * destination_module = "comment", * ) */ class EntityCommentType extends EntityConfigBase { diff --git a/core/modules/field/migration_templates/d7_field.yml b/core/modules/field/migration_templates/d7_field.yml index 1fa00699f9..85bfdf1777 100644 --- a/core/modules/field/migration_templates/d7_field.yml +++ b/core/modules/field/migration_templates/d7_field.yml @@ -9,6 +9,7 @@ source: constants: status: true langcode: und + source_module: field process: entity_type: entity_type status: 'constants/status' diff --git a/core/modules/file/src/Plugin/migrate/destination/EntityFile.php b/core/modules/file/src/Plugin/migrate/destination/EntityFile.php index d0a1cca83d..16ea381508 100644 --- a/core/modules/file/src/Plugin/migrate/destination/EntityFile.php +++ b/core/modules/file/src/Plugin/migrate/destination/EntityFile.php @@ -10,7 +10,8 @@ /** * @MigrateDestination( - * id = "entity:file" + * id = "entity:file", + * destination_module = "file", * ) */ class EntityFile extends EntityContentBase { diff --git a/core/modules/image/src/Plugin/migrate/destination/EntityImageStyle.php b/core/modules/image/src/Plugin/migrate/destination/EntityImageStyle.php index 3fc1e7f4ed..12daa7b6fc 100644 --- a/core/modules/image/src/Plugin/migrate/destination/EntityImageStyle.php +++ b/core/modules/image/src/Plugin/migrate/destination/EntityImageStyle.php @@ -12,7 +12,8 @@ * dependency on the d6_file migration to ensure it runs first. * * @MigrateDestination( - * id = "entity:image_style" + * id = "entity:image_style", + * destination_module = "image", * ) */ class EntityImageStyle extends EntityConfigBase { diff --git a/core/modules/language/src/Plugin/migrate/destination/DefaultLangcode.php b/core/modules/language/src/Plugin/migrate/destination/DefaultLangcode.php index 4d13e9adb4..40b232ca5c 100644 --- a/core/modules/language/src/Plugin/migrate/destination/DefaultLangcode.php +++ b/core/modules/language/src/Plugin/migrate/destination/DefaultLangcode.php @@ -11,7 +11,8 @@ * Provides a destination plugin for the default langcode config. * * @MigrateDestination( - * id = "default_langcode" + * id = "default_langcode", + * destination_module = "language", * ) */ class DefaultLangcode extends Config { diff --git a/core/modules/migrate/src/Plugin/Derivative/MigrateEntity.php b/core/modules/migrate/src/Plugin/Derivative/MigrateEntity.php index 0babe2fc74..641d46fb83 100644 --- a/core/modules/migrate/src/Plugin/Derivative/MigrateEntity.php +++ b/core/modules/migrate/src/Plugin/Derivative/MigrateEntity.php @@ -64,6 +64,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { 'class' => $class, 'requirements_met' => 1, 'provider' => $entity_info->getProvider(), + 'destination_module' => $entity_info->getProvider(), ]; } return $this->derivatives; diff --git a/core/modules/migrate/src/Plugin/Derivative/MigrateEntityRevision.php b/core/modules/migrate/src/Plugin/Derivative/MigrateEntityRevision.php index cee3b3985e..34632b319a 100644 --- a/core/modules/migrate/src/Plugin/Derivative/MigrateEntityRevision.php +++ b/core/modules/migrate/src/Plugin/Derivative/MigrateEntityRevision.php @@ -62,6 +62,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { 'class' => 'Drupal\migrate\Plugin\migrate\destination\EntityRevision', 'requirements_met' => 1, 'provider' => $entity_info->getProvider(), + 'destination_module' => $entity_info->getProvider(), ]; } } diff --git a/core/modules/migrate/src/Plugin/MigrateSourcePluginManager.php b/core/modules/migrate/src/Plugin/MigrateSourcePluginManager.php index 965da5dd76..b4601b25c3 100644 --- a/core/modules/migrate/src/Plugin/MigrateSourcePluginManager.php +++ b/core/modules/migrate/src/Plugin/MigrateSourcePluginManager.php @@ -7,6 +7,7 @@ use Drupal\migrate\Plugin\Discovery\AnnotatedClassDiscoveryAutomatedProviders; use Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator; use Drupal\migrate\Plugin\Discovery\ProviderFilterDecorator; +use Drupal\migrate\Plugin\Exception\BadPluginDefinitionException; /** * Plugin manager for migrate source plugins. @@ -58,6 +59,8 @@ protected function getDiscovery() { * @todo This is a temporary solution to the fact that migration source * plugins have more than one provider. This functionality will be moved to * core in https://www.drupal.org/node/2786355. + * + * @throws \Drupal\migrate\Plugin\Exception\BadPluginDefinitionException */ protected function findDefinitions() { $definitions = $this->getDiscovery()->getDefinitions(); @@ -70,4 +73,15 @@ protected function findDefinitions() { }); } + /** + * {@inheritdoc} + */ + public function processDefinition(&$definition, $plugin_id) { + parent::processDefinition($definition, $plugin_id); + + if (empty($definition['source_module'])) { + throw new BadPluginDefinitionException($plugin_id, 'source_module'); + } + } + } diff --git a/core/modules/migrate/src/Plugin/migrate/destination/Config.php b/core/modules/migrate/src/Plugin/migrate/destination/Config.php index 18d78a325e..3d5b29c49b 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/Config.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/Config.php @@ -66,7 +66,8 @@ * @see \Drupal\migrate_drupal\Plugin\migrate\source\d6\i18nVariable * * @MigrateDestination( - * id = "config" + * id = "config", + * destination_module = "system", * ) */ class Config extends DestinationBase implements ContainerFactoryPluginInterface, DependentPluginInterface { diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityBaseFieldOverride.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityBaseFieldOverride.php index 75232490b7..de20635cb6 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityBaseFieldOverride.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityBaseFieldOverride.php @@ -8,7 +8,8 @@ * Provides entity base field override plugin. * * @MigrateDestination( - * id = "entity:base_field_override" + * id = "entity:base_field_override", + * destination_module = "system", * ) */ class EntityBaseFieldOverride extends EntityConfigBase { diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldInstance.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldInstance.php index a431c4972b..d85babaa8d 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldInstance.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldInstance.php @@ -6,7 +6,8 @@ * Provides entity field instance plugin. * * @MigrateDestination( - * id = "entity:field_config" + * id = "entity:field_config", + * destination_module = "field", * ) */ class EntityFieldInstance extends EntityConfigBase { diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldStorageConfig.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldStorageConfig.php index 9b781a3f9a..04608c0f3a 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldStorageConfig.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldStorageConfig.php @@ -6,7 +6,8 @@ * Provides entity field storage configuration plugin. * * @MigrateDestination( - * id = "entity:field_storage_config" + * id = "entity:field_storage_config", + * destination_module = "field", * ) */ class EntityFieldStorageConfig extends EntityConfigBase { diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php index b0db476987..e243552b2e 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php @@ -11,6 +11,7 @@ * * @MigrateDestination( * id = "entity_revision", + * destination_module = "system", * deriver = "Drupal\migrate\Plugin\Derivative\MigrateEntityRevision" * ) */ diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php index b2c25a4597..309b6b0705 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php @@ -25,7 +25,8 @@ * "targetEntityType") to an "entity_view_mode" entity. * * @MigrateDestination( - * id = "entity:entity_view_mode" + * id = "entity:entity_view_mode", + * destination_module = "system", * ) */ class EntityViewMode extends EntityConfigBase { diff --git a/core/modules/migrate/src/Plugin/migrate/destination/NullDestination.php b/core/modules/migrate/src/Plugin/migrate/destination/NullDestination.php index cfe47eada8..8034003c6f 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/NullDestination.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/NullDestination.php @@ -10,7 +10,7 @@ * * @MigrateDestination( * id = "null", - * requirements_met = false + * requirements_met = false, * ) */ class NullDestination extends DestinationBase { diff --git a/core/modules/migrate/src/Plugin/migrate/destination/PerComponentEntityDisplay.php b/core/modules/migrate/src/Plugin/migrate/destination/PerComponentEntityDisplay.php index 3b9a982f0f..254b389c1d 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/PerComponentEntityDisplay.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/PerComponentEntityDisplay.php @@ -45,7 +45,8 @@ * "options" constant, for example the label will be hidden. * * @MigrateDestination( - * id = "component_entity_display" + * id = "component_entity_display", + * destination_module = "system", * ) */ class PerComponentEntityDisplay extends ComponentEntityDisplayBase { diff --git a/core/modules/migrate/src/Plugin/migrate/destination/PerComponentEntityFormDisplay.php b/core/modules/migrate/src/Plugin/migrate/destination/PerComponentEntityFormDisplay.php index bd837f03f7..f8e10dda3a 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/PerComponentEntityFormDisplay.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/PerComponentEntityFormDisplay.php @@ -38,7 +38,8 @@ * entity type with options defined by the "options" constant. * * @MigrateDestination( - * id = "component_entity_form_display" + * id = "component_entity_form_display", + * destination_module = "system", * ) */ class PerComponentEntityFormDisplay extends ComponentEntityDisplayBase { diff --git a/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php b/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php index 8cee6ddbe4..2be0b5ee53 100644 --- a/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php +++ b/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php @@ -38,7 +38,8 @@ * @see \Drupal\migrate\Plugin\MigrateSourceInterface * * @MigrateSource( - * id = "embedded_data" + * id = "embedded_data", + * source_module = "migrate" * ) */ class EmbeddedDataSource extends SourcePluginBase { diff --git a/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php b/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php index 2391b0a251..4ae99e87f3 100644 --- a/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php +++ b/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php @@ -8,7 +8,8 @@ * This is generally useful when needing to create a field using a migration.. * * @MigrateSource( - * id = "empty" + * id = "empty", + * source_module = "migrate" * ) */ class EmptySource extends SourcePluginBase { diff --git a/core/modules/migrate/tests/modules/migrate_events_test/src/Plugin/migrate/destination/DummyDestination.php b/core/modules/migrate/tests/modules/migrate_events_test/src/Plugin/migrate/destination/DummyDestination.php index 415d000b9c..ad8a555e0c 100644 --- a/core/modules/migrate/tests/modules/migrate_events_test/src/Plugin/migrate/destination/DummyDestination.php +++ b/core/modules/migrate/tests/modules/migrate_events_test/src/Plugin/migrate/destination/DummyDestination.php @@ -9,7 +9,8 @@ /** * @MigrateDestination( * id = "dummy", - * requirements_met = true + * requirements_met = true, + * destination_module = "migrate_events_test", * ) */ class DummyDestination extends DestinationBase { diff --git a/core/modules/migrate/tests/modules/migrate_high_water_test/src/Plugin/migrate/source/HighWaterTest.php b/core/modules/migrate/tests/modules/migrate_high_water_test/src/Plugin/migrate/source/HighWaterTest.php index 601bbd942b..50b70cdfe5 100644 --- a/core/modules/migrate/tests/modules/migrate_high_water_test/src/Plugin/migrate/source/HighWaterTest.php +++ b/core/modules/migrate/tests/modules/migrate_high_water_test/src/Plugin/migrate/source/HighWaterTest.php @@ -8,7 +8,8 @@ * Source plugin for migration high water tests. * * @MigrateSource( - * id = "high_water_test" + * id = "high_water_test", + * source_module = "migrate_high_water_test", * ) */ class HighWaterTest extends SqlBase { diff --git a/core/modules/migrate/tests/modules/migrate_query_batch_test/src/Plugin/migrate/source/QueryBatchTest.php b/core/modules/migrate/tests/modules/migrate_query_batch_test/src/Plugin/migrate/source/QueryBatchTest.php index cc00c0dfa3..c1dd22d252 100644 --- a/core/modules/migrate/tests/modules/migrate_query_batch_test/src/Plugin/migrate/source/QueryBatchTest.php +++ b/core/modules/migrate/tests/modules/migrate_query_batch_test/src/Plugin/migrate/source/QueryBatchTest.php @@ -8,7 +8,8 @@ * Source plugin for migration high water tests. * * @MigrateSource( - * id = "query_batch_test" + * id = "query_batch_test", + * source_module = "migrate_query_batch_test", * ) */ class QueryBatchTest extends SqlBase { diff --git a/core/modules/migrate/tests/src/Kernel/Plugin/MigrationProvidersExistTest.php b/core/modules/migrate/tests/src/Kernel/Plugin/MigrationProvidersExistTest.php index 19a8b24777..3324ef768b 100644 --- a/core/modules/migrate/tests/src/Kernel/Plugin/MigrationProvidersExistTest.php +++ b/core/modules/migrate/tests/src/Kernel/Plugin/MigrationProvidersExistTest.php @@ -2,9 +2,9 @@ namespace Drupal\Tests\migrate\Kernel\Plugin; -use Drupal\Component\Render\FormattableMarkup; use Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait; use Drupal\migrate\Plugin\Exception\BadPluginDefinitionException; +use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate_drupal\Plugin\MigrateFieldPluginManager; use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase; @@ -18,50 +18,76 @@ class MigrationProvidersExistTest extends MigrateDrupalTestBase { use FileSystemModuleDiscoveryDataProviderTrait; /** - * {@inheritdoc} + * Tests that a missing source_module property raises an exception. */ - public static $modules = ['migration_provider_test']; + public function testSourceProvider() { + $this->enableAllModules(); + $this->enableModules(['migration_provider_test']); + $this->setExpectedException(BadPluginDefinitionException::class, 'The no_source_module plugin should define the source_module property.'); + $this->container->get('plugin.manager.migrate.source')->getDefinitions(); + } + + /** + * Tests for missing destination module. + */ + public function testValidDestinationProvider() { + $migration = $this->prophesize(MigrationInterface::class)->reveal(); + $migration->provider = 'provider'; + + $this->enableAllModules(); + $destination_plugin_manager = $this->container->get('plugin.manager.migrate.destination'); + $definitions = $destination_plugin_manager->getDefinitions(); + $configuration = ['config_name' => 'foo']; + + // The destination_module can't be migrate, migrate_drupal, or + // migrate_drupal_ui. + $invalid_destinations = [ + 'migrate', + 'migrate_drupal', + 'migrate_drupal_ui' + ]; + + foreach (array_keys($definitions) as $plugin_id) { + /** @var \Drupal\migrate\Plugin\MigrateDestinationInterface $destination */ + $destination_module = $destination_plugin_manager + ->createInstance($plugin_id, $configuration, $migration) + ->getDestinationModule(); + + $this->assertInternalType('string', $destination_module); + $this->assertNotContains($destination_module, $invalid_destinations, "Invalid destination for plugin $plugin_id."); + } + } /** * Tests that modules exist for all source and destination plugins. */ public function testProvidersExist() { + $this->enableAllModules(); + + /** @var \Drupal\migrate\Plugin\MigrationPluginManager $plugin_manager */ + $plugin_manager = $this->container->get('plugin.manager.migration'); + + // Instantiate all migrations. + $migrations = array_keys($plugin_manager->getDefinitions()); + $migrations = $plugin_manager->createInstances($migrations); + + /** @var \Drupal\migrate\Plugin\MigrationInterface $migration */ + foreach ($migrations as $migration) { + $this->assertInternalType('string', $migration->getSourcePlugin()->getSourceModule()); + $this->assertInternalType('string', $migration->getDestinationPlugin()->getDestinationModule()); + } + } + + /** + * Enable all available modules. + */ + protected function enableAllModules() { // Install all available modules. $module_handler = $this->container->get('module_handler'); $modules = $this->coreModuleListDataProvider(); $modules_enabled = $module_handler->getModuleList(); $modules_to_enable = array_keys(array_diff_key($modules, $modules_enabled)); $this->enableModules($modules_to_enable); - - /** @var \Drupal\migrate\Plugin\MigrationPluginManager $plugin_manager */ - $plugin_manager = $this->container->get('plugin.manager.migration'); - // Get all the migrations. - $migrations = $plugin_manager->createInstances(array_keys($plugin_manager->getDefinitions())); - // Ensure the test module was enabled. - $this->assertTrue(array_key_exists('migration_provider_test', $migrations)); - $this->assertTrue(array_key_exists('migration_provider_no_annotation', $migrations)); - /** @var \Drupal\migrate\Plugin\Migration $migration */ - foreach ($migrations as $migration) { - $source_module = $migration->getSourcePlugin()->getSourceModule(); - $destination_module = $migration->getDestinationPlugin()->getDestinationModule(); - $migration_id = $migration->getPluginId(); - if ($migration_id == 'migration_provider_test') { - $this->assertFalse($source_module, new FormattableMarkup('Source module not found for @migration_id.', ['@migration_id' => $migration_id])); - $this->assertFalse($destination_module, new FormattableMarkup('Destination module not found for @migration_id.', ['@migration_id' => $migration_id])); - } - elseif ($migration_id == 'migration_provider_no_annotation') { - $this->assertFalse($source_module, new FormattableMarkup('Source module not found for @migration_id.', ['@migration_id' => $migration_id])); - $this->assertTrue($destination_module, new FormattableMarkup('Destination module found for @migration_id.', ['@migration_id' => $migration_id])); - } - else { - $this->assertTrue($source_module, new FormattableMarkup('Source module found for @migration_id.', ['@migration_id' => $migration_id])); - $this->assertTrue($destination_module, new FormattableMarkup('Destination module found for @migration_id.', ['@migration_id' => $migration_id])); - } - // Destination module can't be migrate or migrate_drupal or - // migrate_drupal_ui. - $invalid_destinations = ['migrate', 'migrate_drupal', 'migrate_drupal_ui']; - $this->assertNotContains($destination_module, $invalid_destinations, new FormattableMarkup('Invalid destination for @migration_id.', ['@migration_id' => $migration_id])); - } } /** @@ -150,16 +176,9 @@ public function testFieldProvidersExist() { 'destination_module' => 'core', ], ]; - // Install all available modules. - $module_handler = $this->container->get('module_handler'); - $modules = $this->coreModuleListDataProvider(); - $modules_enabled = $module_handler->getModuleList(); - $modules_to_enable = array_keys(array_diff_key($modules, $modules_enabled)); - $this->enableModules($modules_to_enable); + $this->enableAllModules(); - /** @var \Drupal\migrate_drupal\Plugin\MigrateFieldPluginManager $plugin_manager */ - $plugin_manager = $this->container->get('plugin.manager.migrate.field'); - $definitions = $plugin_manager->getDefinitions(); + $definitions = $this->container->get('plugin.manager.migrate.field')->getDefinitions(); foreach ($definitions as $key => $definition) { $this->assertArrayHasKey($key, $expected_mappings); $this->assertEquals($expected_mappings[$key]['source_module'], $definition['source_module']); diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/destination/EntityFieldStorageConfig.php b/core/modules/migrate_drupal/src/Plugin/migrate/destination/EntityFieldStorageConfig.php index c5e631a0e6..a076e2465e 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/destination/EntityFieldStorageConfig.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/destination/EntityFieldStorageConfig.php @@ -14,7 +14,8 @@ * Deprecated. Destination with Drupal specific config dependencies. * * @MigrateDestination( - * id = "md_entity:field_storage_config" + * id = "md_entity:field_storage_config", + * destination_module = "field", * ) * * @deprecated in Drupal 8.2.x and will be removed in Drupal 9.0.x. Use diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php index e0acc4b52e..03b3526aee 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php @@ -14,7 +14,8 @@ * Source returning an empty row with Drupal specific config dependencies. * * @MigrateSource( - * id = "md_empty" + * id = "md_empty", + * source_module = "system" * ) */ class EmptySource extends BaseEmptySource implements ContainerFactoryPluginInterface, DependentPluginInterface { diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php index 410acec229..e8b1ee0f03 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php @@ -13,7 +13,8 @@ * example for any normal source class returning multiple rows. * * @MigrateSource( - * id = "variable" + * id = "variable", + * source_module = "system" * ) */ class Variable extends DrupalSqlBase { diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/VariableMultiRow.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/VariableMultiRow.php index 61da5eb30a..02b324538c 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/VariableMultiRow.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/VariableMultiRow.php @@ -11,7 +11,8 @@ * variable. * * @MigrateSource( - * id = "variable_multirow" + * id = "variable_multirow", + * source_module = "system" * ) */ class VariableMultiRow extends DrupalSqlBase { diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/VariableTranslation.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/VariableTranslation.php index 566a8402e0..3dd5a7690e 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/VariableTranslation.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/VariableTranslation.php @@ -11,7 +11,8 @@ * Drupal i18n_variable source from database. * * @MigrateSource( - * id = "variable_translation" + * id = "variable_translation", + * source_module = "system" * ) */ class VariableTranslation extends DrupalSqlBase { diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/i18nVariable.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/i18nVariable.php index dd8d0f0741..8e6c391232 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/i18nVariable.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/i18nVariable.php @@ -8,7 +8,8 @@ * Drupal i18n_variable source from database. * * @MigrateSource( - * id = "i18n_variable" + * id = "i18n_variable", + * source_module = "system" * ) * * @deprecated in Drupal 8.4.x and will be removed in Drupal 9.0.x. Use diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d8/Config.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d8/Config.php index 8d8338776d..5ae76b93b3 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/d8/Config.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d8/Config.php @@ -9,7 +9,8 @@ * Drupal config source from database. * * @MigrateSource( - * id = "d8_config" + * id = "d8_config", + * source_module = "system" * ) */ class Config extends DrupalSqlBase { diff --git a/core/modules/migrate_drupal_ui/tests/modules/migration_provider_test/migration_templates/migration_provider_test.yml b/core/modules/migrate_drupal_ui/tests/modules/migration_provider_test/migration_templates/migration_provider_test.yml deleted file mode 100644 index d3afc66539..0000000000 --- a/core/modules/migrate_drupal_ui/tests/modules/migration_provider_test/migration_templates/migration_provider_test.yml +++ /dev/null @@ -1,16 +0,0 @@ -id: migration_provider_test -label: Missing source and destination provider -migration_tags: - - Drupal 6 - - Drupal 7 -source: - plugin: variable - variables: - - site_offline_message -# Do not add a provider for the test. -process: - message: site_offline_message -destination: - plugin: config -# An empty config_name will not have a destination provider. - config_name: \ No newline at end of file diff --git a/core/modules/migrate_drupal_ui/tests/modules/migration_provider_test/migration_templates/migration_provider_no_annotation.yml b/core/modules/migrate_drupal_ui/tests/modules/migration_provider_test/migrations/migration_provider_no_annotation.yml similarity index 84% rename from core/modules/migrate_drupal_ui/tests/modules/migration_provider_test/migration_templates/migration_provider_no_annotation.yml rename to core/modules/migrate_drupal_ui/tests/modules/migration_provider_test/migrations/migration_provider_no_annotation.yml index bdc906660b..09d0b6e5bc 100644 --- a/core/modules/migrate_drupal_ui/tests/modules/migration_provider_test/migration_templates/migration_provider_no_annotation.yml +++ b/core/modules/migrate_drupal_ui/tests/modules/migration_provider_test/migrations/migration_provider_no_annotation.yml @@ -9,5 +9,4 @@ source: process: message: site_offline_message destination: - plugin: config - config_name: test.settings + plugin: no_destination_module diff --git a/core/modules/migrate_drupal_ui/tests/modules/migration_provider_test/src/Plugin/migrate/destination/NoDestinationModule.php b/core/modules/migrate_drupal_ui/tests/modules/migration_provider_test/src/Plugin/migrate/destination/NoDestinationModule.php new file mode 100644 index 0000000000..e66121012d --- /dev/null +++ b/core/modules/migrate_drupal_ui/tests/modules/migration_provider_test/src/Plugin/migrate/destination/NoDestinationModule.php @@ -0,0 +1,14 @@ +sourceDatabase->getConnectionOptions(); $this->drupalGet('/upgrade'); - $this->assertSession()->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal 8.'); + $web_assert = $this->assertSession(); + $web_assert->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal 8.'); $this->drupalPostForm(NULL, [], t('Continue')); - $this->assertText('Provide credentials for the database of the Drupal site you want to upgrade.'); - $this->assertFieldByName('mysql[host]'); + $web_assert->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.'); + $web_assert->fieldExists('mysql[host]'); $driver = $connection_options['driver']; $connection_options['prefix'] = $connection_options['prefix']['default']; @@ -148,36 +149,35 @@ public function testMigrateUpgrade() { // Ensure submitting the form with invalid database credentials gives us a // nice warning. $this->drupalPostForm(NULL, [$driver . '[database]' => 'wrong'] + $edits, t('Review upgrade')); - $this->assertText('Resolve the issue below to continue the upgrade.'); + $web_assert->pageTextContains('Resolve the issue below to continue the upgrade.'); $this->drupalPostForm(NULL, $edits, t('Review upgrade')); - $this->assertResponse(200); - $this->assertText('Upgrade analysis report'); + $web_assert->statusCodeEquals(200); + // Ensure we get errors about missing modules. - $this->assertSession()->pageTextContains(t('Source module not found for migration_provider_no_annotation.')); - $this->assertSession()->pageTextContains(t('Source module not found for migration_provider_test.')); - $this->assertSession()->pageTextContains(t('Destination module not found for migration_provider_test')); + $web_assert->pageTextContains(t('Resolve the issue below to continue the upgrade')); + $web_assert->pageTextContains(t('The no_source_module plugin should define the source_module property.')); // Uninstall the module causing the missing module error messages. $this->container->get('module_installer')->uninstall(['migration_provider_test'], TRUE); // Restart the upgrade process. $this->drupalGet('/upgrade'); - $this->assertSession()->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal 8.'); + $web_assert->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal 8.'); $this->drupalPostForm(NULL, [], t('Continue')); - $this->assertSession()->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.'); - $this->assertSession()->fieldExists('mysql[host]'); + $web_assert->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.'); + $web_assert->fieldExists('mysql[host]'); $this->drupalPostForm(NULL, $edits, t('Review upgrade')); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->pageTextContains('Upgrade analysis report'); + $web_assert->statusCodeEquals(200); + $web_assert->pageTextContains('Upgrade analysis report'); // Ensure there are no errors about the missing modules from the test module. - $this->assertSession()->pageTextNotContains(t('Source module not found for migration_provider_no_annotation.')); - $this->assertSession()->pageTextNotContains(t('Source module not found for migration_provider_test.')); - $this->assertSession()->pageTextNotContains(t('Destination module not found for migration_provider_test')); + $web_assert->pageTextNotContains(t('Source module not found for migration_provider_no_annotation.')); + $web_assert->pageTextNotContains(t('Source module not found for migration_provider_test.')); + $web_assert->pageTextNotContains(t('Destination module not found for migration_provider_test')); // Ensure there are no errors about any other missing migration providers. - $this->assertSession()->pageTextNotContains(t('module not found')); + $web_assert->pageTextNotContains(t('module not found')); // Test the available migration paths. $all_available = $this->getAvailablePaths(); diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php index 3cfe4bc6d7..e4235964fe 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php @@ -97,7 +97,6 @@ protected function getAvailablePaths() { 'email', 'entityreference', 'field', - 'field_sql_storage', 'file', 'filefield', 'filter', diff --git a/core/modules/node/src/Plugin/migrate/destination/EntityNodeType.php b/core/modules/node/src/Plugin/migrate/destination/EntityNodeType.php index c26f3b9f1c..c83623215f 100644 --- a/core/modules/node/src/Plugin/migrate/destination/EntityNodeType.php +++ b/core/modules/node/src/Plugin/migrate/destination/EntityNodeType.php @@ -7,7 +7,8 @@ /** * @MigrateDestination( - * id = "entity:node_type" + * id = "entity:node_type", + * destination_module = "node", * ) */ class EntityNodeType extends EntityConfigBase { diff --git a/core/modules/path/src/Plugin/migrate/destination/UrlAlias.php b/core/modules/path/src/Plugin/migrate/destination/UrlAlias.php index a845fb3908..87a4c2ec3d 100644 --- a/core/modules/path/src/Plugin/migrate/destination/UrlAlias.php +++ b/core/modules/path/src/Plugin/migrate/destination/UrlAlias.php @@ -11,7 +11,8 @@ /** * @MigrateDestination( - * id = "url_alias" + * id = "url_alias", + * destination_module = "path", * ) */ class UrlAlias extends DestinationBase implements ContainerFactoryPluginInterface { diff --git a/core/modules/search/src/Plugin/migrate/destination/EntitySearchPage.php b/core/modules/search/src/Plugin/migrate/destination/EntitySearchPage.php index ddd8da7956..03f109a349 100644 --- a/core/modules/search/src/Plugin/migrate/destination/EntitySearchPage.php +++ b/core/modules/search/src/Plugin/migrate/destination/EntitySearchPage.php @@ -8,7 +8,8 @@ /** * @MigrateDestination( - * id = "entity:search_page" + * id = "entity:search_page", + * destination_module = "search", * ) */ class EntitySearchPage extends EntityConfigBase { diff --git a/core/modules/shortcut/src/Plugin/migrate/destination/EntityShortcutSet.php b/core/modules/shortcut/src/Plugin/migrate/destination/EntityShortcutSet.php index fddf08a712..4c794baa75 100644 --- a/core/modules/shortcut/src/Plugin/migrate/destination/EntityShortcutSet.php +++ b/core/modules/shortcut/src/Plugin/migrate/destination/EntityShortcutSet.php @@ -7,7 +7,8 @@ /** * @MigrateDestination( - * id = "entity:shortcut_set" + * id = "entity:shortcut_set", + * destination_module = "shortcut", * ) */ class EntityShortcutSet extends EntityConfigBase { diff --git a/core/modules/shortcut/src/Plugin/migrate/destination/ShortcutSetUsers.php b/core/modules/shortcut/src/Plugin/migrate/destination/ShortcutSetUsers.php index 0cb843be76..0a4e19bf00 100644 --- a/core/modules/shortcut/src/Plugin/migrate/destination/ShortcutSetUsers.php +++ b/core/modules/shortcut/src/Plugin/migrate/destination/ShortcutSetUsers.php @@ -12,7 +12,8 @@ /** * @MigrateDestination( - * id = "shortcut_set_users" + * id = "shortcut_set_users", + * destination_module = "shortcut", * ) */ class ShortcutSetUsers extends DestinationBase implements ContainerFactoryPluginInterface { diff --git a/core/modules/system/src/Plugin/migrate/destination/EntityDateFormat.php b/core/modules/system/src/Plugin/migrate/destination/EntityDateFormat.php index 42ba1661c3..acdffae74c 100644 --- a/core/modules/system/src/Plugin/migrate/destination/EntityDateFormat.php +++ b/core/modules/system/src/Plugin/migrate/destination/EntityDateFormat.php @@ -7,7 +7,8 @@ /** * @MigrateDestination( - * id = "entity:date_format" + * id = "entity:date_format", + * destination_module = "system", * ) */ class EntityDateFormat extends EntityConfigBase { diff --git a/core/modules/system/src/Plugin/migrate/destination/d7/ThemeSettings.php b/core/modules/system/src/Plugin/migrate/destination/d7/ThemeSettings.php index 55ac721d8a..b7f935cba4 100644 --- a/core/modules/system/src/Plugin/migrate/destination/d7/ThemeSettings.php +++ b/core/modules/system/src/Plugin/migrate/destination/d7/ThemeSettings.php @@ -13,7 +13,8 @@ * Persist theme settings to the config system. * * @MigrateDestination( - * id = "d7_theme_settings" + * id = "d7_theme_settings", + * destination_module = "system", * ) */ class ThemeSettings extends DestinationBase implements ContainerFactoryPluginInterface { diff --git a/core/modules/user/src/Plugin/migrate/destination/EntityUser.php b/core/modules/user/src/Plugin/migrate/destination/EntityUser.php index 7c2c81af96..f5fb9ea795 100644 --- a/core/modules/user/src/Plugin/migrate/destination/EntityUser.php +++ b/core/modules/user/src/Plugin/migrate/destination/EntityUser.php @@ -16,7 +16,8 @@ /** * @MigrateDestination( - * id = "entity:user" + * id = "entity:user", + * destination_module = "user", * ) */ class EntityUser extends EntityContentBase { diff --git a/core/modules/user/src/Plugin/migrate/destination/UserData.php b/core/modules/user/src/Plugin/migrate/destination/UserData.php index 7c48f93e6d..8843deb687 100644 --- a/core/modules/user/src/Plugin/migrate/destination/UserData.php +++ b/core/modules/user/src/Plugin/migrate/destination/UserData.php @@ -11,7 +11,8 @@ /** * @MigrateDestination( - * id = "user_data" + * id = "user_data", + * destination_module = "user", * ) */ class UserData extends DestinationBase implements ContainerFactoryPluginInterface {