function MigrateSqlIdMapTest::testLookupDestinationId

Tests lookupDestinationId().

@group legacy @expectedDeprecation Drupal\migrate\Plugin\migrate\id_map\Sql::lookupDestinationId() is deprecated in drupal:8.1.0 and is removed from drupal:9.0.0. Use Sql::lookupDestinationIds() instead. See https://www.drupal.org/node/2725809

File

core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php, line 569

Class

MigrateSqlIdMapTest
Tests the SQL ID map plugin.

Namespace

Drupal\Tests\migrate\Unit

Code

public function testLookupDestinationId() {
    // Simple map with one source and one destination ID.
    $id_map = $this->setupRows([
        'nid',
    ], [
        'nid',
    ], [
        [
            1,
            101,
        ],
        [
            2,
            102,
        ],
        [
            3,
            103,
        ],
    ]);
    // Lookup nothing, gives nothing.
    $this->assertEquals([], $id_map->lookupDestinationId([]));
    // Lookup by complete non-associative list.
    $this->assertEquals([
        101,
    ], $id_map->lookupDestinationId([
        1,
    ]));
    $this->assertEquals([], $id_map->lookupDestinationId([
        99,
    ]));
    // Lookup by complete associative list.
    $this->assertEquals([
        101,
    ], $id_map->lookupDestinationId([
        'nid' => 1,
    ]));
}

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