Unverified Commit bb5c5a35 authored by alexpott's avatar alexpott

Issue #2835989 by gwagroves, Jo Fitzgerald, alexpott:...

Issue #2835989 by gwagroves, Jo Fitzgerald, alexpott: DatabaseQueue::numberOfItems should return an integer
parent 16726375
......@@ -100,7 +100,7 @@ protected function doCreateItem($data) {
*/
public function numberOfItems() {
try {
return $this->connection->query('SELECT COUNT(item_id) FROM {' . static::TABLE_NAME . '} WHERE name = :name', [':name' => $this->name])
return (int) $this->connection->query('SELECT COUNT(item_id) FROM {' . static::TABLE_NAME . '} WHERE name = :name', [':name' => $this->name])
->fetchField();
}
catch (\Exception $e) {
......
......@@ -37,7 +37,7 @@ public function createItem($data);
* result might only be valid for a fraction of a second and not provide an
* accurate representation.
*
* @return
* @return int
* An integer estimate of the number of items in the queue.
*/
public function numberOfItems();
......
......@@ -76,8 +76,8 @@ protected function runQueueTest($queue1, $queue2) {
$queue1->createItem($data[2]);
$queue1->createItem($data[3]);
$this->assertTrue($queue1->numberOfItems(), 'Queue 1 is not empty after adding items.');
$this->assertFalse($queue2->numberOfItems(), 'Queue 2 is empty while Queue 1 has items');
$this->assertSame(4, $queue1->numberOfItems(), 'Queue 1 is not empty after adding items.');
$this->assertSame(0, $queue2->numberOfItems(), 'Queue 2 is empty while Queue 1 has items');
$items[] = $item = $queue1->claimItem();
$new_items[] = $item->data;
......@@ -98,8 +98,8 @@ protected function runQueueTest($queue1, $queue2) {
}
// Check that both queues are empty.
$this->assertFalse($queue1->numberOfItems(), 'Queue 1 is empty');
$this->assertFalse($queue2->numberOfItems(), 'Queue 2 is empty');
$this->assertSame(0, $queue1->numberOfItems(), 'Queue 1 is empty');
$this->assertSame(0, $queue2->numberOfItems(), 'Queue 2 is empty');
}
/**
......
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