function MigrateSqlIdMapTest::testSaveIdMapping
Same name in other branches
- 9 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testSaveIdMapping()
- 8.9.x core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testSaveIdMapping()
- 10 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testSaveIdMapping()
Tests the ID mapping method.
Create two ID mappings and update the second to verify that:
- saving new to empty tables work.
- saving new to nonempty tables work.
- updating work.
File
-
core/
modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapTest.php, line 164
Class
- MigrateSqlIdMapTest
- Tests the SQL ID map plugin.
Namespace
Drupal\Tests\migrate\UnitCode
public function testSaveIdMapping() : void {
$source = [
'source_id_property' => 'source_value',
];
$row = new Row($source, [
'source_id_property' => [],
]);
$id_map = $this->getIdMap();
$id_map->saveIdMapping($row, [
'destination_id_property' => 2,
]);
$expected_result = [
[
'sourceid1' => 'source_value',
'source_ids_hash' => $this->getIdMap()
->getSourceIdsHash($source),
'destid1' => 2,
] + $this->idMapDefaults(),
];
$this->queryResultTest($this->getIdMapContents(), $expected_result);
$source = [
'source_id_property' => 'source_value_1',
];
$row = new Row($source, [
'source_id_property' => [],
]);
$id_map->saveIdMapping($row, [
'destination_id_property' => 3,
]);
$expected_result[] = [
'sourceid1' => 'source_value_1',
'source_ids_hash' => $this->getIdMap()
->getSourceIdsHash($source),
'destid1' => 3,
] + $this->idMapDefaults();
$this->queryResultTest($this->getIdMapContents(), $expected_result);
$id_map->saveIdMapping($row, [
'destination_id_property' => 4,
]);
$expected_result[1]['destid1'] = 4;
$this->queryResultTest($this->getIdMapContents(), $expected_result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.