function MigrateSqlIdMapTest::testProcessedCount
Same name in other branches
- 9 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testProcessedCount()
- 8.9.x core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testProcessedCount()
- 10 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testProcessedCount()
Tests the number of processed source rows.
Scenarios to test for:
- No processed rows.
- One processed row.
- Multiple processed rows.
File
-
core/
modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapTest.php, line 763
Class
- MigrateSqlIdMapTest
- Tests the SQL ID map plugin.
Namespace
Drupal\Tests\migrate\UnitCode
public function testProcessedCount() : void {
$id_map = $this->getIdMap();
// Assert zero rows have been processed before adding rows.
$this->assertSame(0, $id_map->processedCount());
$row_statuses = [
MigrateIdMapInterface::STATUS_IMPORTED,
MigrateIdMapInterface::STATUS_NEEDS_UPDATE,
MigrateIdMapInterface::STATUS_IGNORED,
MigrateIdMapInterface::STATUS_FAILED,
];
// Create a mapping row for each STATUS constant.
foreach ($row_statuses as $status) {
$source = [
'source_id_property' => 'source_value_' . $status,
];
$row = new Row($source, [
'source_id_property' => [],
]);
$destination = [
'destination_id_property' => 'destination_value_' . $status,
];
$id_map->saveIdMapping($row, $destination, $status);
if ($status == MigrateIdMapInterface::STATUS_IMPORTED) {
// Assert a single row has been processed.
$this->assertSame(1, $id_map->processedCount());
}
}
// Assert multiple rows have been processed.
$this->assertSame(count($row_statuses), $id_map->processedCount());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.