Issue #3012001 by quietone, rkostov, ellenoise: Duplications within migration process plugin

merge-requests/55/head
catch 2019-09-17 10:53:33 +01:00
parent 58abc5cdc1
commit ddfcac8d27
2 changed files with 30 additions and 3 deletions

View File

@ -278,7 +278,7 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
$this->destinationPluginManager = $destination_plugin_manager; $this->destinationPluginManager = $destination_plugin_manager;
$this->idMapPluginManager = $idmap_plugin_manager; $this->idMapPluginManager = $idmap_plugin_manager;
foreach (NestedArray::mergeDeep($plugin_definition, $configuration) as $key => $value) { foreach (NestedArray::mergeDeepArray([$plugin_definition, $configuration], TRUE) as $key => $value) {
$this->$key = $value; $this->$key = $value;
} }
} }

View File

@ -20,6 +20,7 @@ class MigrationPluginConfigurationTest extends KernelTestBase {
'migrate_drupal', 'migrate_drupal',
// Test with a simple migration. // Test with a simple migration.
'ban', 'ban',
'locale',
]; ];
/** /**
@ -27,9 +28,10 @@ class MigrationPluginConfigurationTest extends KernelTestBase {
* *
* @dataProvider mergeProvider * @dataProvider mergeProvider
*/ */
public function testConfigurationMerge($configuration, $expected) { public function testConfigurationMerge($id, $configuration, $expected) {
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */ /** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
$migration = $this->container->get('plugin.manager.migration')->createInstance('d7_blocked_ips', $configuration); $migration = $this->container->get('plugin.manager.migration')
->createInstance($id, $configuration);
$source_configuration = $migration->getSourceConfiguration(); $source_configuration = $migration->getSourceConfiguration();
$this->assertEquals($expected, $source_configuration); $this->assertEquals($expected, $source_configuration);
} }
@ -42,6 +44,7 @@ class MigrationPluginConfigurationTest extends KernelTestBase {
// Tests adding new configuration to a migration. // Tests adding new configuration to a migration.
[ [
// New configuration. // New configuration.
'd7_blocked_ips',
[ [
'source' => [ 'source' => [
'constants' => [ 'constants' => [
@ -60,6 +63,7 @@ class MigrationPluginConfigurationTest extends KernelTestBase {
// Tests overriding pre-existing configuration in a migration. // Tests overriding pre-existing configuration in a migration.
[ [
// New configuration. // New configuration.
'd7_blocked_ips',
[ [
'source' => [ 'source' => [
'plugin' => 'a_different_plugin', 'plugin' => 'a_different_plugin',
@ -70,6 +74,29 @@ class MigrationPluginConfigurationTest extends KernelTestBase {
'plugin' => 'a_different_plugin', 'plugin' => 'a_different_plugin',
], ],
], ],
// New configuration.
[
'locale_settings',
[
'source' => [
'plugin' => 'variable',
'variables' => [
'locale_cache_strings',
'locale_js_directory',
],
'source_module' => 'locale',
],
],
// Expected final source and process configuration.
[
'plugin' => 'variable',
'variables' => [
'locale_cache_strings',
'locale_js_directory',
],
'source_module' => 'locale',
],
],
]; ];
} }