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 fd2f42c..44b23db 100644 --- a/core/modules/file/src/Plugin/migrate/process/d6/CckFile.php +++ b/core/modules/file/src/Plugin/migrate/process/d6/CckFile.php @@ -50,11 +50,9 @@ 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 - // the d6_file migration. - $migration_plugin_configuration = [ - 'source' => ['fid'], - 'migration' => 'd6_file', - ]; + // a d6 file migration. + $migration_plugin_configuration = ['source' => ['fid']] + $configuration; + $migration_plugin_configuration += ['migration' => 'd6_file']; return new static( $configuration, @@ -100,5 +98,4 @@ public function transform($value, MigrateExecutableInterface $migrate_executable return []; } } - } diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php index 1ee73a8..929f8c2 100644 --- a/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php @@ -3,13 +3,18 @@ namespace Drupal\Tests\file\Unit\Plugin\migrate\process\d6; use Drupal\file\Plugin\migrate\process\d6\CckFile; +use Drupal\migrate\Plugin\migrate\process\Migration; +use Drupal\migrate\Plugin\MigratePluginManager; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Plugin\MigrateProcessInterface; +use Drupal\migrate\Plugin\MigrationPluginManager; use Drupal\migrate\Row; use Drupal\Tests\UnitTestCase; /** + * @coversDefaultClass \Drupal\file\Plugin\migrate\process\d6\CckFile + * * @group file */ class CckFileTest extends UnitTestCase { @@ -48,4 +53,40 @@ public function testTransformAltTitle() { $this->assertSame($expected, $transformed); } + /** + * Tests initialization of the iterator. + * + * @covers ::__construct + */ +/* public function testConfigurableFileMigration() { + $migration = $this->prophesize(MigrationInterface::class)->reveal(); + $migration_plugin = $this->prophesize(MigrateProcessInterface::class); + + $migrationPluginManager = $this->getMockClass(MigrationPluginManager::class, ['createInstance']); + $migrationProcessPlugin = $this->prophesize(TestableMigration::class); + $migrationPluginManager::staticExpects + $migrationPluginManager->createInstance()->willReturn($migrationProcessPlugin); + $testableMigration = new CckFile(['migration' => 'custom_file'], 'custom_file', [], $migration, $migration_plugin->reveal()); + + $this->assertEquals('custom_file', $migrationProcessPlugin->getConfiguration()['migration']); + }*/ + +} + +/** + * 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; + } }