You are here

public function MigrateLookupTest::testLookup in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/migrate/tests/src/Unit/MigrateLookupTest.php \Drupal\Tests\migrate\Unit\MigrateLookupTest::testLookup()
  2. 10 core/modules/migrate/tests/src/Unit/MigrateLookupTest.php \Drupal\Tests\migrate\Unit\MigrateLookupTest::testLookup()

Tests the lookup function.

@covers ::lookup

File

core/modules/migrate/tests/src/Unit/MigrateLookupTest.php, line 26

Class

MigrateLookupTest
Provides unit testing for the migration lookup service.

Namespace

Drupal\Tests\migrate\Unit

Code

public function testLookup() {
  $source_ids = [
    'id' => '1',
  ];
  $destination_ids = [
    [
      2,
    ],
  ];
  $id_map = $this
    ->prophesize(MigrateIdMapInterface::class);
  $id_map
    ->lookupDestinationIds($source_ids)
    ->willReturn($destination_ids);
  $destination = $this
    ->prophesize(MigrateDestinationInterface::class);
  $destination
    ->getIds()
    ->willReturn([
    'id' => [
      'type' => 'integer',
    ],
  ]);
  $migration = $this
    ->prophesize(MigrationInterface::class);
  $migration
    ->getIdMap()
    ->willReturn($id_map
    ->reveal());
  $migration
    ->getDestinationPlugin()
    ->willReturn($destination
    ->reveal());
  $plugin_manager = $this
    ->prophesize(MigrationPluginManagerInterface::class);
  $plugin_manager
    ->createInstances('test_migration')
    ->willReturn([
    $migration
      ->reveal(),
  ]);
  $lookup = new MigrateLookup($plugin_manager
    ->reveal());
  $this
    ->assertSame([
    [
      'id' => 2,
    ],
  ], $lookup
    ->lookup('test_migration', $source_ids));
}