Skip to content
Snippets Groups Projects
Unverified Commit b1007e34 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2969231 by quietone, NickDickinsonWilde, joachim, xjm: errors in...

Issue #2969231 by quietone, NickDickinsonWilde, joachim, xjm: errors in migration process configuration don't give a clear message

(cherry picked from commit 93545bd5)
parent 041612a3
No related branches found
No related tags found
9 merge requests!1445Issue #2920039: Views' User Name exposed group filter validation,!1298Issue #3240993: Let layout builder render inline block translations,!774Issue #3174569: Example node template file name is incorrect,!497Issue #2463967: Use .user.ini file for PHP settings,!433Resolve #3163663 "Too many open files",!233Resolve #2693787 "Taxonomy term name",!133Resolve #2666286 "Clean up menuui",!112Resolve #3187004 "Drupaldatetime serialization issue",!53Resolve #3181870: Correct typo "the the" in "core/classList" deprecation message.
...@@ -405,6 +405,10 @@ protected function getProcessNormalized(array $process) { ...@@ -405,6 +405,10 @@ protected function getProcessNormalized(array $process) {
if (isset($configuration['plugin'])) { if (isset($configuration['plugin'])) {
$configuration = [$configuration]; $configuration = [$configuration];
} }
if (!is_array($configuration)) {
$migration_id = $this->getPluginId();
throw new MigrateException("Invalid process for destination '$destination' in migration '$migration_id'");
}
$normalized_configurations[$destination] = $configuration; $normalized_configurations[$destination] = $configuration;
} }
return $normalized_configurations; return $normalized_configurations;
......
...@@ -42,23 +42,64 @@ public function testGetProcessPluginsException() { ...@@ -42,23 +42,64 @@ public function testGetProcessPluginsException() {
} }
/** /**
* Tests Migration::getDestinationPlugin() * Tests Migration::getProcessPlugins()
* *
* @covers ::getDestinationPlugin * @param array $process
* The migration process pipeline.
*
* @covers ::getProcessPlugins
*
* @dataProvider getProcessPluginsExceptionMessageProvider
*/ */
public function testGetProcessPluginsExceptionMessage() { public function testGetProcessPluginsExceptionMessage(array $process) {
// Test with an invalid process pipeline. // Test with an invalid process pipeline.
$plugin_definition = [ $plugin_definition = [
'process' => [ 'id' => 'foo',
'dest1' => 123, 'process' => $process,
],
]; ];
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($plugin_definition);
reset($process);
$destination = key(($process));
$migration = \Drupal::service('plugin.manager.migration')
->createStubMigration($plugin_definition);
$this->expectException(MigrateException::class); $this->expectException(MigrateException::class);
$this->expectExceptionMessage("Process configuration for 'dest1' must be an array"); $this->expectExceptionMessage("Invalid process for destination '$destination' in migration 'foo'");
$migration->getProcessPlugins(); $migration->getProcessPlugins();
} }
/**
* Provides data for testing invalid process pipeline.
*/
public function getProcessPluginsExceptionMessageProvider() {
return [
[
'Null' =>
[
'dest' => NULL,
],
],
[
'boolean' =>
[
'dest' => TRUE,
],
],
[
'integer' =>
[
'dest' => 2370,
],
],
[
'float' =>
[
'dest' => 1.61,
],
],
];
}
/** /**
* Tests Migration::getMigrationDependencies() * Tests Migration::getMigrationDependencies()
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment