only in patch2: unchanged: --- a/core/modules/migrate/tests/src/Kernel/Plugin/MigrationProvidersExistTest.php +++ b/core/modules/migrate/tests/src/Kernel/Plugin/MigrationProvidersExistTest.php @@ -2,6 +2,8 @@ namespace Drupal\Tests\migrate\Kernel\Plugin; +use Drupal\Component\Discovery\DiscoveryException; +use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException; use Drupal\Component\Render\FormattableMarkup; use Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait; use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase; @@ -16,49 +18,58 @@ class MigrationProvidersExistTest extends MigrateDrupalTestBase { use FileSystemModuleDiscoveryDataProviderTrait; /** - * {@inheritdoc} + * Tests missing source module. */ - public static $modules = ['migration_provider_test']; + public function testSourceProvider() { + $this->enableAllModules(); + $this->enableModules(['migration_provider_test']); + $source_plugin_manager = $this->container->get('plugin.manager.migrate.source'); + $this->setExpectedException(InvalidPluginDefinitionException::class, 'The Drupal\migration_provider_test\Plugin\migrate\source\NoSourceModule plugin should define the source_module property.'); + $source_plugin_manager->getDefinitions(); + } + + /** + * Tests missing destination module. + */ + public function testDestinationProvider() { + $this->enableAllModules(); + $this->enableModules(['migration_provider_test']); + $destination_plugin_manager = $this->container->get('plugin.manager.migrate.destination'); + $this->setExpectedException(InvalidPluginDefinitionException::class, 'The Drupal\migration_provider_test\Plugin\migrate\destination\NoDestinationModule plugin should define the destination_module property.'); + $destination_plugin_manager->getDefinitions(); + } /** * Tests that modules exist for all source and destination plugins. */ public function testProvidersExist() { - // 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(); + // Get all the migrations /** @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])); } } + /** + * Enable all available modules. + * + * @throws \Exception + */ + 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); + } + } only in patch2: unchanged: --- 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/migration_templates/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 only in patch2: unchanged: --- 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 only in patch2: unchanged: --- /dev/null +++ b/core/modules/migrate_drupal_ui/tests/modules/migration_provider_test/src/Plugin/migrate/destination/NoDestinationModule.php @@ -0,0 +1,15 @@ +drupalPostForm(NULL, $edits, t('Review upgrade')); $this->assertResponse(200); - $this->assertText('Are you sure?'); // 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')); + $this->assertSession()->pageTextContains(t('Resolve the issue below to continue the upgrade')); + $this->assertSession()->pageTextContains(t('NoSourceModule 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);