function MigrateSqlIdMapTest::testGetRowByDestination
Same name in other branches
- 9 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testGetRowByDestination()
- 8.9.x core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testGetRowByDestination()
- 11.x core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testGetRowByDestination()
Tests the getRowByDestination method.
File
-
core/
modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapTest.php, line 562
Class
- MigrateSqlIdMapTest
- Tests the SQL ID map plugin.
Namespace
Drupal\Tests\migrate\UnitCode
public function testGetRowByDestination() : void {
$row = [
'sourceid1' => 'source_id_value_1',
'sourceid2' => 'source_id_value_2',
'source_ids_hash' => $this->getIdMap()
->getSourceIdsHash([
'source_id_property' => 'source_id_value_1',
]),
'destid1' => 'destination_id_value_1',
] + $this->idMapDefaults();
$this->saveMap($row);
$row = [
'sourceid1' => 'source_id_value_3',
'sourceid2' => 'source_id_value_4',
'source_ids_hash' => $this->getIdMap()
->getSourceIdsHash([
'source_id_property' => 'source_id_value_3',
]),
'destid1' => 'destination_id_value_2',
] + $this->idMapDefaults();
$this->saveMap($row);
$dest_id_values = [
'destination_id_property' => $row['destid1'],
];
$id_map = $this->getIdMap();
$result_row = $id_map->getRowByDestination($dest_id_values);
$this->assertSame($row, $result_row);
// This value does not exist, getRowByDestination should return an (empty)
// array.
// @see \Drupal\migrate\Plugin\MigrateIdMapInterface::getRowByDestination()
$missing_result_row = $id_map->getRowByDestination([
'destination_id_property' => 'invalid_destination_id_property',
]);
$this->assertEquals([], $missing_result_row);
// The destination ID values array does not contain all the destination ID
// keys, we expect an empty array.
$invalid_result_row = $id_map->getRowByDestination([
'invalid_destination_key' => 'invalid_destination_id_property',
]);
$this->assertEquals([], $invalid_result_row);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.