function MigrateSqlIdMapTest::setupRows
Same name in other branches
- 9 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::setupRows()
- 8.9.x core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::setupRows()
- 11.x core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::setupRows()
Setup a database with the given rows.
Parameters
array $source_keys: The source keys for the ID map table.
array $dest_keys: The destination keys for the ID map table.
array $rows: An array of source and destination value arrays for the ID map table.
Return value
\Drupal\Tests\migrate\Unit\TestSqlIdMap An ID map instance for testing.
2 calls to MigrateSqlIdMapTest::setupRows()
- MigrateSqlIdMapTest::testCurrentDestinationAndSource in core/
modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapTest.php - Tests currentDestination() and currentSource().
- MigrateSqlIdMapTest::testLookupDestinationIds in core/
modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapTest.php - Tests lookupDestinationIds().
File
-
core/
modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapTest.php, line 453
Class
- MigrateSqlIdMapTest
- Tests the SQL ID map plugin.
Namespace
Drupal\Tests\migrate\UnitCode
protected function setupRows($source_keys, $dest_keys, $rows) {
$this->database = $this->getDatabase([]);
$this->sourceIds = array_fill_keys($source_keys, []);
$this->destinationIds = array_fill_keys($dest_keys, []);
$db_keys = [];
foreach (array_keys($source_keys) as $i) {
$db_keys[] = 'sourceid' . ($i + 1);
}
foreach (array_keys($dest_keys) as $i) {
$db_keys[] = 'destid' . ($i + 1);
}
foreach ($rows as $row) {
$values = array_combine($db_keys, $row);
$source_values = array_slice($row, 0, count($source_keys));
$values['source_ids_hash'] = $this->getIdMap()
->getSourceIdsHash($source_values);
$this->saveMap($values);
}
return $this->getIdMap();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.