diff -u b/core/modules/migrate/src/MigrateExecutable.php b/core/modules/migrate/src/MigrateExecutable.php --- b/core/modules/migrate/src/MigrateExecutable.php +++ b/core/modules/migrate/src/MigrateExecutable.php @@ -15,7 +15,6 @@ use Drupal\migrate\Event\MigratePostRowSaveEvent; use Drupal\migrate\Event\MigratePreRowSaveEvent; use Drupal\migrate\Exception\RequirementsException; -use Drupal\migrate\Plugin\migrate\process\Migration; use Drupal\migrate\Plugin\MigrateIdMapInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; only in patch2: unchanged: --- a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php @@ -227,9 +227,10 @@ public function testImportWithValidRowNoDestinationValues() { } /** - * Tests the import method with a MigrateException being thrown. + * Tests the import method with a MigrateException being thrown from the + * destination. */ - public function testImportWithValidRowWithMigrateException() { + public function testImportWithValidRowWithDestinationMigrateException() { $exception_message = $this->getRandomGenerator()->string(); $source = $this->getMockSource(); @@ -268,10 +269,6 @@ public function testImportWithValidRowWithMigrateException() { $this->idMap->expects($this->once()) ->method('saveMessage'); - $this->message->expects($this->once()) - ->method('display') - ->with($exception_message); - $this->idMap->expects($this->once()) ->method('lookupDestinationId') ->with(array('id' => 'test')) @@ -281,6 +278,54 @@ public function testImportWithValidRowWithMigrateException() { } /** + * Tests the import method with a MigrateException being thrown from a process + * plugin. + */ + public function testImportWithValidRowWithProcesMigrateException() { + $exception_message = $this->getRandomGenerator()->string(); + $source = $this->getMockSource(); + + $row = $this->getMockBuilder('Drupal\migrate\Row') + ->disableOriginalConstructor() + ->getMock(); + + $row->expects($this->once()) + ->method('getSourceIdValues') + ->will($this->returnValue(array('id' => 'test'))); + + $source->expects($this->once()) + ->method('current') + ->will($this->returnValue($row)); + + $this->executable->setSource($source); + + $this->migration->expects($this->once()) + ->method('getProcessPlugins') + ->will($this->returnValue(array())) + ->will($this->throwException(new MigrateException($exception_message))); + + $destination = $this->getMock('Drupal\migrate\Plugin\MigrateDestinationInterface'); + $destination->expects($this->never()) + ->method('import'); + + $this->migration->expects($this->once()) + ->method('getDestinationPlugin') + ->will($this->returnValue($destination)); + + $this->idMap->expects($this->once()) + ->method('saveIdMapping') + ->with($row, array(), MigrateIdMapInterface::STATUS_FAILED, NULL); + + $this->idMap->expects($this->once()) + ->method('saveMessage'); + + $this->idMap->expects($this->never()) + ->method('lookupDestinationId'); + + $this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import()); + } + + /** * Tests the import method with a regular Exception being thrown. */ public function testImportWithValidRowWithException() {