diff --git a/core/modules/file/src/Plugin/migrate/process/d6/CckFile.php b/core/modules/file/src/Plugin/migrate/process/d6/CckFile.php index 44b23db..748eff0 100644 --- a/core/modules/file/src/Plugin/migrate/process/d6/CckFile.php +++ b/core/modules/file/src/Plugin/migrate/process/d6/CckFile.php @@ -51,8 +51,10 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { // Configure the migration process plugin to look up migrated IDs from // a d6 file migration. - $migration_plugin_configuration = ['source' => ['fid']] + $configuration; - $migration_plugin_configuration += ['migration' => 'd6_file']; + $migration_plugin_configuration = $configuration + [ + 'migration' => 'd6_file', + 'source' => ['fid'], + ]; return new static( $configuration, diff --git a/core/modules/file/tests/src/Kernel/Migrate/process/d6/CckFileTest.php b/core/modules/file/tests/src/Kernel/Migrate/process/d6/CckFileTest.php index 120a22c..1c60c95 100644 --- a/core/modules/file/tests/src/Kernel/Migrate/process/d6/CckFileTest.php +++ b/core/modules/file/tests/src/Kernel/Migrate/process/d6/CckFileTest.php @@ -1,13 +1,9 @@ prophesize(MigrationInterface::class)->reveal(); - $cache = $this->prophesize(CacheBackendInterface::class)->reveal(); - $moduleHandler = $this->prophesize(ModuleHandlerInterface::class)->reveal(); - $migrationPluginManager = new TestableMigratePluginManager('process', new \ArrayObject(), $cache, $moduleHandler); - $this->container->set('plugin.manager.migrate.process', $migrationPluginManager); - $testableMigration = TestableCckFile::create($this->container, ['migration' => 'custom_file'], 'custom_file', [], $migration); + $migration = Migration::create($this->container, [], 'custom_migration', []); + $cck_file_migration = CckFile::create($this->container, ['migration' => 'custom_file'], 'custom_file', [], $migration); + $migration_plugin = $this->readAttribute($cck_file_migration, 'migrationPlugin'); + $config = $this->readAttribute($migration_plugin, 'configuration'); - $this->assertEquals('custom_file', $testableMigration->getMigrationPlugin()->getConfiguration()['migration']); - } - -} - -/** - * Class TestableMigration - * - * Provide a means to test the cck file migration. - */ -class TestableCckFile extends CckFile { - - /** - * Return the migration process plugin. - * - * @return array - * The migration process plugin. - */ - public function getMigrationPlugin() { - return $this->migrationPlugin; - } -} - -/** - * Class TestableMigration - * - * Provide a means to test the cck file migration. - */ -class TestableMigration extends Migration { - - /** - * Return the migration process plugin. - * - * @return array - * The configuration for the migration process plugin. - */ - public function getConfiguration() { - return $this->configuration; - } -} - -/** - * Class TestableMigratePluginManager - * - * Provides a means to provide a testable migration process plugin. - */ -class TestableMigratePluginManager extends MigratePluginManager { - public function createInstance($pluginId, array $configuration = [], MigrationInterface $migration = NULL) { - return TestableMigration::create(\Drupal::getContainer(), $configuration, $pluginId, [], $migration); + $this->assertEquals($config['migration'], 'custom_file'); } }