function MigrateLookupTest::testMultipleMigrationLookup

Same name in other branches
  1. 9 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()
  3. 11.x 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 140

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);
}

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