function MigrateLookupTest::testMultipleSourceIds

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

Tests lookups with multiple source ids.

File

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

Class

MigrateLookupTest
Tests the Migrate Lookup service.

Namespace

Drupal\Tests\migrate\Kernel

Code

public function testMultipleSourceIds() : void {
    $this->executeMigration('sample_lookup_migration_multiple_source_ids');
    // Test with full set of numerically indexed source ids.
    $result = $this->migrateLookup
        ->lookup('sample_lookup_migration_multiple_source_ids', [
        25,
        26,
    ]);
    $this->assertCount(1, $result);
    $this->assertSame('3', $result[0]['nid']);
    // Test with full set of associatively indexed source ids.
    $result = $this->migrateLookup
        ->lookup('sample_lookup_migration_multiple_source_ids', [
        'id' => 17,
        'version_id' => 17,
    ]);
    $this->assertCount(1, $result);
    $this->assertSame('1', $result[0]['nid']);
    // Test with full set of associatively indexed source ids in the wrong
    // order.
    $result = $this->migrateLookup
        ->lookup('sample_lookup_migration_multiple_source_ids', [
        'version_id' => 26,
        'id' => 25,
    ]);
    $this->assertCount(1, $result);
    $this->assertSame('3', $result[0]['nid']);
    // Test with a partial set of numerically indexed ids.
    $result = $this->migrateLookup
        ->lookup('sample_lookup_migration_multiple_source_ids', [
        25,
    ]);
    $this->assertCount(2, $result);
    $this->assertSame('2', $result[0]['nid']);
    $this->assertSame('3', $result[1]['nid']);
    // Test with a partial set of associatively indexed ids.
    $result = $this->migrateLookup
        ->lookup('sample_lookup_migration_multiple_source_ids', [
        'version_id' => 25,
    ]);
    $this->assertCount(1, $result);
    $this->assertSame('2', $result[0]['nid']);
}

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