function MigrationLookupTest::testSuccessfulLookup

Same name in other branches
  1. 9 core/modules/migrate/tests/src/Unit/process/MigrationLookupTest.php \Drupal\Tests\migrate\Unit\process\MigrationLookupTest::testSuccessfulLookup()
  2. 8.9.x core/modules/migrate/tests/src/Unit/process/MigrationLookupTest.php \Drupal\Tests\migrate\Unit\process\MigrationLookupTest::testSuccessfulLookup()
  3. 10 core/modules/migrate/tests/src/Unit/process/MigrationLookupTest.php \Drupal\Tests\migrate\Unit\process\MigrationLookupTest::testSuccessfulLookup()

Tests a successful lookup.

@dataProvider successfulLookupDataProvider

Parameters

array $source_id_values: The source id(s) of the migration map.

array $destination_id_values: The destination id(s) of the migration map.

string|array $source_value: The source value(s) for the migration process plugin.

string|array $expected_value: The expected value(s) of the migration process plugin.

Throws

\Drupal\Component\Plugin\Exception\PluginException

\Drupal\migrate\MigrateException

File

core/modules/migrate/tests/src/Unit/process/MigrationLookupTest.php, line 198

Class

MigrationLookupTest
@coversDefaultClass \Drupal\migrate\Plugin\migrate\process\MigrationLookup @group migrate

Namespace

Drupal\Tests\migrate\Unit\process

Code

public function testSuccessfulLookup(array $source_id_values, array $destination_id_values, $source_value, $expected_value) : void {
    $migration_plugin = $this->prophesize(MigrationInterface::class);
    $this->migrateLookup
        ->lookup('foo', $source_id_values)
        ->willReturn([
        $destination_id_values,
    ]);
    $configuration = [
        'migration' => 'foo',
    ];
    $migration = MigrationLookup::create($this->prepareContainer(), $configuration, '', [], $migration_plugin->reveal());
    $this->assertSame($expected_value, $migration->transform($source_value, $this->migrateExecutable, $this->row, 'foo'));
}

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