diff -u b/core/modules/migrate_drupal/src/Tests/MigrateDrupalTestBase.php b/core/modules/migrate_drupal/src/Tests/MigrateDrupalTestBase.php --- b/core/modules/migrate_drupal/src/Tests/MigrateDrupalTestBase.php +++ b/core/modules/migrate_drupal/src/Tests/MigrateDrupalTestBase.php @@ -9,8 +9,7 @@ use Drupal\migrate\Tests\MigrateTestBase; use Drupal\migrate\Entity\Migration; -use Drupal\migrate\MigrationStorage; -use Drupal\Component\Plugin\Exception\PluginNotFoundException; +use Drupal\Core\Config\ConfigInstaller; /** * Base class for Drupal migration tests. @@ -53,18 +52,15 @@ * Drupal version as provided in migration_tags - e.g., 'Drupal 6'. */ protected function installMigrations($version) { + /** @var ConfigInstaller $config_installer */ + $config_installer = \Drupal::service('config.installer'); $migration_templates = \Drupal::service('migrate.template_storage')->findTemplatesByTag($version); + $all_template_names = array_keys($migration_templates); foreach ($migration_templates as $template_name => $template) { - try { + if ($config_installer->validateDependenciesWrapper($template_name, $template, $all_template_names)) { $migration = Migration::create($template); $migration->save(); } - catch (PluginNotFoundException $e) { - // Migrations requiring modules not enabled will throw an exception. - // Ignoring this exception is equivalent to placing config in the - // optional subdirectory - the migrations we require for the test will - // be successfully saved. - } } } } only in patch2: unchanged: --- a/core/lib/Drupal/Core/Config/ConfigInstaller.php +++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php @@ -528,6 +528,14 @@ protected function validateDependencies($config_name, array $data, array $enable } /** + * {@inheritdoc} + */ + public function validateDependenciesWrapper($config_name, array $data, array $additional_config) { + $all_config = array_merge($this->getActiveStorages()->listAll(), $additional_config); + return $this->validateDependencies($config_name, $data, $this->getEnabledExtensions(), $all_config); + } + + /** * Gets the list of enabled extensions including both modules and themes. * * @return array only in patch2: unchanged: --- a/core/lib/Drupal/Core/Config/ConfigInstallerInterface.php +++ b/core/lib/Drupal/Core/Config/ConfigInstallerInterface.php @@ -110,4 +110,18 @@ public function isSyncing(); */ public function checkConfigurationToInstall($type, $name); + /** + * Validates an array of config data that contains dependency information. + * + * @param string $config_name + * The name of the configuration object that is being validated. + * @param array $data + * Configuration data. + * @param array $additional_config + * List of configuration names to be considered as present. + * + * @return bool + * TRUE if the dependencies are met, FALSE if not. + */ + public function validateDependenciesWrapper($config_name, array $data, array $additional_config); }