function MigrateSqlIdMapTest::doTestLookupSourceIdMapping
Same name in other branches
- 10 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::doTestLookupSourceIdMapping()
Performs the source ID test on source and destination fields.
@dataProvider lookupSourceIdMappingDataProvider
Parameters
int $num_source_fields: Number of source fields to test.
int $num_destination_fields: Number of destination fields to test.
string $source_id_property_prefix: Prefix for the source ID properties.
2 calls to MigrateSqlIdMapTest::doTestLookupSourceIdMapping()
- MigrateSqlIdMapTest::testLookupSourceIdMapping in core/
modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapTest.php - Performs the source ID test on source and destination fields.
- MigrateSqlIdMapTest::testLookupSourceIdMappingNonSqlCharacters in core/
modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapTest.php - Performs the source ID test on source and destination fields.
File
-
core/
modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapTest.php, line 661
Class
- MigrateSqlIdMapTest
- Tests the SQL ID map plugin.
Namespace
Drupal\Tests\migrate\UnitCode
public function doTestLookupSourceIdMapping(int $num_source_fields, int $num_destination_fields, string $source_id_property_prefix) : void {
// Adjust the migration configuration according to the number of source and
// destination fields.
$this->sourceIds = [];
$this->destinationIds = [];
$row = $this->idMapDefaults();
$source_ids_values = [];
$expected_result = [];
for ($i = 1; $i <= $num_source_fields; $i++) {
$row["sourceid{$i}"] = "source_id_value_{$i}";
$source_ids_values = [
$row["sourceid{$i}"],
];
$expected_result[$source_id_property_prefix . $i] = "source_id_value_{$i}";
$this->sourceIds[$source_id_property_prefix . $i] = [];
}
$destination_id_values = [];
$nonexistent_id_values = [];
for ($i = 1; $i <= $num_destination_fields; $i++) {
$row["destid{$i}"] = "destination_id_value_{$i}";
$destination_id_values["destination_id_property_{$i}"] = "destination_id_value_{$i}";
$nonexistent_id_values["destination_id_property_{$i}"] = "nonexistent_destination_id_value_{$i}";
$this->destinationIds["destination_id_property_{$i}"] = [];
}
$row['source_ids_hash'] = $this->getIdMap()
->getSourceIdsHash($source_ids_values);
$this->saveMap($row);
$id_map = $this->getIdMap();
// Test for a valid hit.
$source_id = $id_map->lookupSourceId($destination_id_values);
$this->assertSame($expected_result, $source_id);
// Test for a miss.
$source_id = $id_map->lookupSourceId($nonexistent_id_values);
$this->assertCount(0, $source_id);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.