Commit 2421ca24 authored by alexpott's avatar alexpott

Issue #2846002 by Jo Fitzgerald, joachim: Pipeline failure exceptions should...

Issue #2846002 by Jo Fitzgerald, joachim: Pipeline failure exceptions should say which plugin they failed at
parent 7e3c8582
......@@ -358,7 +358,7 @@ public function processRow(Row $row, array $process = NULL, $value = NULL) {
if ($multiple && !$definition['handle_multiples']) {
$new_value = [];
if (!is_array($value)) {
throw new MigrateException(sprintf('Pipeline failed for destination %s: %s got instead of an array,', $destination, $value));
throw new MigrateException(sprintf('Pipeline failed at %s plugin for destination %s: %s received instead of an array,', $plugin->getPluginId(), $destination, $value));
}
$break = FALSE;
foreach ($value as $scalar_value) {
......
......@@ -3,6 +3,7 @@
namespace Drupal\Tests\migrate\Unit;
use Drupal\Component\Utility\Html;
use Drupal\migrate\Plugin\MigrateProcessInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\MigrateException;
......@@ -419,6 +420,25 @@ public function testProcessRowEmptyPipeline() {
$this->assertSame($row->getDestination(), []);
}
/**
* Tests the processRow pipeline exception.
*/
public function testProcessRowPipelineException() {
$row = new Row();
$plugin = $this->prophesize(MigrateProcessInterface::class);
$plugin->getPluginDefinition()->willReturn(['handle_multiples' => FALSE]);
$plugin->transform(NULL, $this->executable, $row, 'destination_id')
->willReturn('transform_return_string');
$plugin->multiple()->willReturn(TRUE);
$plugin->getPluginId()->willReturn('plugin_id');
$plugin = $plugin->reveal();
$plugins['destination_id'] = [$plugin, $plugin];
$this->migration->method('getProcessPlugins')->willReturn($plugins);
$this->setExpectedException(MigrateException::class, 'Pipeline failed at plugin_id plugin for destination destination_id: transform_return_string received instead of an array,');
$this->executable->processRow($row);
}
/**
* Returns a mock migration source instance.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment