Commit 7ecda050 authored by catch's avatar catch

Issue #2937666 by Jo Fitzgerald, quietone: errorCount() returns string not int as documented

parent 40d6328e
......@@ -696,7 +696,7 @@ public function prepareUpdate() {
* {@inheritdoc}
*/
public function processedCount() {
return $this->getDatabase()->select($this->mapTableName())
return (int) $this->getDatabase()->select($this->mapTableName())
->countQuery()
->execute()
->fetchField();
......@@ -706,7 +706,7 @@ public function processedCount() {
* {@inheritdoc}
*/
public function importedCount() {
return $this->getDatabase()->select($this->mapTableName())
return (int) $this->getDatabase()->select($this->mapTableName())
->condition('source_row_status', [MigrateIdMapInterface::STATUS_IMPORTED, MigrateIdMapInterface::STATUS_NEEDS_UPDATE], 'IN')
->countQuery()
->execute()
......@@ -750,7 +750,7 @@ protected function countHelper($status, $table = NULL) {
if (isset($status)) {
$query->condition('source_row_status', $status);
}
return $query->countQuery()->execute()->fetchField();
return (int) $query->countQuery()->execute()->fetchField();
}
/**
......
......@@ -381,7 +381,7 @@ protected function fetchNextBatch() {
* {@inheritdoc}
*/
public function count($refresh = FALSE) {
return $this->query()->countQuery()->execute()->fetchField();
return (int) $this->query()->countQuery()->execute()->fetchField();
}
/**
......
......@@ -211,10 +211,10 @@ public function testClearMessages() {
}
// Truncate and check that 4 messages were deleted.
$this->assertEquals($id_map->messageCount(), 4);
$this->assertSame($id_map->messageCount(), 4);
$id_map->clearMessages();
$count = $id_map->messageCount();
$this->assertEquals($count, 0);
$this->assertSame($count, 0);
}
/**
......@@ -284,7 +284,7 @@ public function testMessageCount() {
// Test count message multiple times starting from 0.
foreach ($expected_results as $key => $expected_result) {
$count = $id_map->messageCount();
$this->assertEquals($expected_result, $count);
$this->assertSame($expected_result, $count);
$id_map->saveMessage(['source_id_property' => $key], $message);
}
}
......@@ -684,21 +684,21 @@ public function testImportedCount() {
$row = new Row($source, ['source_id_property' => []]);
$destination = ['destination_id_property' => 'destination_value_failed'];
$id_map->saveIdMapping($row, $destination, MigrateIdMapInterface::STATUS_FAILED);
$this->assertSame(0, (int) $id_map->importedCount());
$this->assertSame(0, $id_map->importedCount());
// Add an imported row and assert single count.
$source = ['source_id_property' => 'source_value_imported'];
$row = new Row($source, ['source_id_property' => []]);
$destination = ['destination_id_property' => 'destination_value_imported'];
$id_map->saveIdMapping($row, $destination, MigrateIdMapInterface::STATUS_IMPORTED);
$this->assertSame(1, (int) $id_map->importedCount());
$this->assertSame(1, $id_map->importedCount());
// Add a row needing update and assert multiple imported rows.
$source = ['source_id_property' => 'source_value_update'];
$row = new Row($source, ['source_id_property' => []]);
$destination = ['destination_id_property' => 'destination_value_update'];
$id_map->saveIdMapping($row, $destination, MigrateIdMapInterface::STATUS_NEEDS_UPDATE);
$this->assertSame(2, (int) $id_map->importedCount());
$this->assertSame(2, $id_map->importedCount());
}
/**
......@@ -712,7 +712,7 @@ public function testImportedCount() {
public function testProcessedCount() {
$id_map = $this->getIdMap();
// Assert zero rows have been processed before adding rows.
$this->assertSame(0, (int) $id_map->processedCount());
$this->assertSame(0, $id_map->processedCount());
$row_statuses = [
MigrateIdMapInterface::STATUS_IMPORTED,
MigrateIdMapInterface::STATUS_NEEDS_UPDATE,
......@@ -727,11 +727,11 @@ public function testProcessedCount() {
$id_map->saveIdMapping($row, $destination, $status);
if ($status == MigrateIdMapInterface::STATUS_IMPORTED) {
// Assert a single row has been processed.
$this->assertSame(1, (int) $id_map->processedCount());
$this->assertSame(1, $id_map->processedCount());
}
}
// Assert multiple rows have been processed.
$this->assertSame(count($row_statuses), (int) $id_map->processedCount());
$this->assertSame(count($row_statuses), $id_map->processedCount());
}
/**
......@@ -779,7 +779,7 @@ public function testUpdateCount($num_update_rows) {
$this->saveMap($row);
}
$id_map = $this->getIdMap();
$this->assertSame($num_update_rows, (int) $id_map->updateCount());
$this->assertSame($num_update_rows, $id_map->updateCount());
}
/**
......@@ -827,7 +827,7 @@ public function testErrorCount($num_error_rows) {
$this->saveMap($row);
}
$this->assertSame($num_error_rows, (int) $this->getIdMap()->errorCount());
$this->assertSame($num_error_rows, $this->getIdMap()->errorCount());
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment