function MigrateStubTest::testCreateStub
Tests stubbing.
@covers ::createStub
      
    
File
- 
              core/modules/ migrate/ tests/ src/ Unit/ MigrateStubTest.php, line 45 
Class
- MigrateStubTest
- Tests the migrate stub service.
Namespace
Drupal\Tests\migrate\UnitCode
public function testCreateStub() {
  $destination_plugin = $this->prophesize(MigrateDestinationInterface::class);
  $destination_plugin->import(Argument::type(Row::class))
    ->willReturn([
    'id' => 2,
  ]);
  $source_plugin = $this->prophesize(MigrateSourceInterface::class);
  $source_plugin->getIds()
    ->willReturn([
    'id' => [
      'type' => 'integer',
    ],
  ]);
  $id_map = $this->prophesize(MigrateIdMapInterface::class);
  $migration = $this->prophesize(MigrationInterface::class);
  $migration->getIdMap()
    ->willReturn($id_map->reveal());
  $migration->getDestinationPlugin(TRUE)
    ->willReturn($destination_plugin->reveal());
  $migration->getProcessPlugins([])
    ->willReturn([]);
  $migration->getProcess()
    ->willReturn([]);
  $migration->getSourceConfiguration()
    ->willReturn([]);
  $migration->getSourcePlugin()
    ->willReturn($source_plugin->reveal());
  $this->migrationPluginManager
    ->createInstances([
    'test_migration',
  ])
    ->willReturn([
    $migration->reveal(),
  ]);
  $stub = new MigrateStub($this->migrationPluginManager
    ->reveal());
  $this->assertSame([
    'id' => 2,
  ], $stub->createStub('test_migration', [
    'id' => 1,
  ], []));
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
