You are here

public function MigrateLookupTest::testMultipleMigrationLookup in Drupal 9

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

Tests looking up against multiple migrations at once.

Throws

\Drupal\Component\Plugin\Exception\PluginException

\Drupal\migrate\MigrateException

File

core/modules/migrate/tests/src/Kernel/MigrateLookupTest.php, line 129

Class

MigrateLookupTest
Tests the Migrate Lookup service.

Namespace

Drupal\Tests\migrate\Kernel

Code

public function testMultipleMigrationLookup() {
  $migrations = [
    'sample_lookup_migration',
    'sample_lookup_migration_2',
  ];
  foreach ($migrations as $migration) {
    $this
      ->executeMigration($migration);
  }

  // Test numerically indexed source id.
  $result = $this->migrateLookup
    ->lookup($migrations, [
    17,
  ]);
  $this
    ->assertSame('1', $result[0]['nid']);

  // Test associatively indexed source id.
  $result = $this->migrateLookup
    ->lookup($migrations, [
    'id' => 35,
  ]);
  $this
    ->assertSame('4', $result[0]['nid']);

  // Test lookup not found.
  $result = $this->migrateLookup
    ->lookup($migrations, [
    1337,
  ]);
  $this
    ->assertSame([], $result);
}