function MigrateLookupTest::testLookupWithStringIds

Same name and namespace in other branches
  1. 9 core/modules/migrate/tests/src/Kernel/MigrateLookupTest.php \Drupal\Tests\migrate\Kernel\MigrateLookupTest::testLookupWithStringIds()
  2. 8.9.x core/modules/migrate/tests/src/Kernel/MigrateLookupTest.php \Drupal\Tests\migrate\Kernel\MigrateLookupTest::testLookupWithStringIds()
  3. 11.x 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 156

Class

MigrateLookupTest
Tests the Migrate Lookup service.

Namespace

Drupal\Tests\migrate\Kernel

Code

public function testLookupWithStringIds() : void {
  $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);
}

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