function MigrateExecutableTest::testStopPipeline
Same name in other branches
- 11.x core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php \Drupal\Tests\migrate\Unit\MigrateExecutableTest::testStopPipeline()
Tests a plugin which stops the pipeline.
File
-
core/
modules/ migrate/ tests/ src/ Unit/ MigrateExecutableTest.php, line 353
Class
- MigrateExecutableTest
- @coversDefaultClass \Drupal\migrate\MigrateExecutable @group migrate
Namespace
Drupal\Tests\migrate\UnitCode
public function testStopPipeline() : void {
$row = new Row();
// Prophesize a plugin that stops the pipeline and returns 'first_plugin'.
$stop_plugin = $this->prophesize(MigrateProcessInterface::class);
$stop_plugin->getPluginDefinition()
->willReturn([
'handle_multiples' => FALSE,
]);
$stop_plugin->transform(NULL, $this->executable, $row, 'destination_id')
->willReturn('first_plugin');
$stop_plugin->multiple()
->willReturn(FALSE);
$stop_plugin->reset()
->shouldBeCalled();
$stop_plugin->isPipelineStopped()
->willReturn(TRUE);
// Prophesize a plugin that transforms 'first_plugin' to 'final_plugin'.
$final_plugin = $this->prophesize(MigrateProcessInterface::class);
$final_plugin->getPluginDefinition()
->willReturn([
'handle_multiples' => FALSE,
]);
$final_plugin->transform('first_plugin', $this->executable, $row, 'destination_id')
->willReturn('final_plugin');
$plugins['destination_id'] = [
$stop_plugin->reveal(),
$final_plugin->reveal(),
];
$this->migration
->method('getProcessPlugins')
->willReturn($plugins);
// Process the row and confirm that destination value is 'first_plugin'.
$this->executable
->processRow($row);
$this->assertEquals('first_plugin', $row->getDestinationProperty('destination_id'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.