function MigrateExecutableTest::testContinuePipeline

Same name in other branches
  1. 10 core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php \Drupal\Tests\migrate\Unit\MigrateExecutableTest::testContinuePipeline()

Tests a plugin which does not stop the pipeline.

File

core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php, line 358

Class

MigrateExecutableTest
@coversDefaultClass \Drupal\migrate\MigrateExecutable @group migrate

Namespace

Drupal\Tests\migrate\Unit

Code

public function testContinuePipeline() : void {
    $row = new Row();
    // Prophesize a plugin that does not stop the pipeline.
    $continue_plugin = $this->prophesize(MigrateProcessInterface::class);
    $continue_plugin->getPluginDefinition()
        ->willReturn([
        'handle_multiples' => FALSE,
    ]);
    $continue_plugin->transform(NULL, $this->executable, $row, 'destination_id')
        ->willReturn('first_plugin');
    $continue_plugin->multiple()
        ->willReturn(FALSE);
    $continue_plugin->reset()
        ->shouldBeCalled();
    $continue_plugin->isPipelineStopped()
        ->willReturn(FALSE);
    // 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');
    $final_plugin->multiple()
        ->willReturn(FALSE);
    $final_plugin->reset()
        ->shouldBeCalled();
    $final_plugin->isPipelineStopped()
        ->willReturn(FALSE);
    $plugins['destination_id'] = [
        $continue_plugin->reveal(),
        $final_plugin->reveal(),
    ];
    $this->migration
        ->method('getProcessPlugins')
        ->willReturn($plugins);
    // Process the row and confirm that the destination value is 'final_plugin'.
    $this->executable
        ->processRow($row);
    $this->assertEquals('final_plugin', $row->getDestinationProperty('destination_id'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.