public function MigrateSqlIdMapTest::testIterators in Drupal 9
Same name and namespace in other branches
- 8 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testIterators()
Tests all the iterator methods in one swing.
The iterator methods are:
- Sql::rewind()
- Sql::next()
- Sql::valid()
- Sql::key()
- Sql::current()
File
- core/
modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapTest.php, line 987
Class
- MigrateSqlIdMapTest
- Tests the SQL ID map plugin.
Namespace
Drupal\Tests\migrate\UnitCode
public function testIterators() {
for ($i = 0; $i < 3; $i++) {
$row = $this
->idMapDefaults();
$row['sourceid1'] = "source_id_value_{$i}";
$row['source_ids_hash'] = $this
->getIdMap()
->getSourceIdsHash([
'source_id_property' => $row['sourceid1'],
]);
$row['destid1'] = "destination_id_value_{$i}";
$row['source_row_status'] = MigrateIdMapInterface::STATUS_IMPORTED;
$expected_results[serialize([
'sourceid1' => $row['sourceid1'],
])] = [
'destid1' => $row['destid1'],
];
$this
->saveMap($row);
}
$this
->assertSame(iterator_to_array($this
->getIdMap()), $expected_results);
}