You are here

public function MigrateLookupTest::testLookupWithStringIds in Drupal 8

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

Tests a lookup with string source ids.

File

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

Class

MigrateLookupTest
Tests the Migrate Lookup service.

Namespace

Drupal\Tests\migrate\Kernel

Code

public function testLookupWithStringIds() {
  $this
    ->executeMigration('sample_lookup_migration_string_ids');

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

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

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