You are here

public function MigrateStubTest::testCreateStub in Drupal 9

Same name in this branch
  1. 9 core/modules/migrate/tests/src/Unit/MigrateStubTest.php \Drupal\Tests\migrate\Unit\MigrateStubTest::testCreateStub()
  2. 9 core/modules/migrate/tests/src/Kernel/MigrateStubTest.php \Drupal\Tests\migrate\Kernel\MigrateStubTest::testCreateStub()
Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Unit/MigrateStubTest.php \Drupal\Tests\migrate\Unit\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\Unit

Code

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,
  ], []));
}