function MigrateLookupTest::testSingleLookup

Same name in other branches
  1. 9 core/modules/migrate/tests/src/Kernel/MigrateLookupTest.php \Drupal\Tests\migrate\Kernel\MigrateLookupTest::testSingleLookup()
  2. 8.9.x core/modules/migrate/tests/src/Kernel/MigrateLookupTest.php \Drupal\Tests\migrate\Kernel\MigrateLookupTest::testSingleLookup()
  3. 10 core/modules/migrate/tests/src/Kernel/MigrateLookupTest.php \Drupal\Tests\migrate\Kernel\MigrateLookupTest::testSingleLookup()

Tests scenarios around single id lookups.

File

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

Class

MigrateLookupTest
Tests the Migrate Lookup service.

Namespace

Drupal\Tests\migrate\Kernel

Code

public function testSingleLookup() : void {
    $this->executeMigration('sample_lookup_migration');
    // Test numerically indexed source id.
    $result = $this->migrateLookup
        ->lookup('sample_lookup_migration', [
        17,
    ]);
    $this->assertSame('1', $result[0]['nid']);
    // Test associatively indexed source id.
    $result = $this->migrateLookup
        ->lookup('sample_lookup_migration', [
        'id' => 25,
    ]);
    $this->assertSame('2', $result[0]['nid']);
    // Test lookup not found.
    $result = $this->migrateLookup
        ->lookup('sample_lookup_migration', [
        1337,
    ]);
    $this->assertSame([], $result);
}

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