function MigrateStubTest::testCreateStub

Same name in this branch
  1. 11.x core/modules/migrate/tests/src/Kernel/MigrateStubTest.php \Drupal\Tests\migrate\Kernel\MigrateStubTest::testCreateStub()
Same name in other branches
  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()
  3. 8.9.x core/modules/migrate/tests/src/Unit/MigrateStubTest.php \Drupal\Tests\migrate\Unit\MigrateStubTest::testCreateStub()
  4. 8.9.x core/modules/migrate/tests/src/Kernel/MigrateStubTest.php \Drupal\Tests\migrate\Kernel\MigrateStubTest::testCreateStub()
  5. 10 core/modules/migrate/tests/src/Unit/MigrateStubTest.php \Drupal\Tests\migrate\Unit\MigrateStubTest::testCreateStub()
  6. 10 core/modules/migrate/tests/src/Kernel/MigrateStubTest.php \Drupal\Tests\migrate\Kernel\MigrateStubTest::testCreateStub()

Tests stubbing.

@covers ::createStub

File

core/modules/migrate/tests/src/Unit/MigrateStubTest.php, line 47

Class

MigrateStubTest
Tests the migrate stub service.

Namespace

Drupal\Tests\migrate\Unit

Code

public function testCreateStub() : void {
    $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.