Skip to content

Commit

Permalink
Ranged selects always miss the last range
Browse files Browse the repository at this point in the history
Fix unit test. 11 batches expected to handle 105 items:

1: 1-10
2: 11-20
3: 21-30
4: 31-40
5: 41-50
6: 51-60
7: 61-70
8: 71-80
9: 81-90
10: 91-100
11: 101-105
  • Loading branch information
Anton Evers authored and Anton Evers committed Jan 11, 2018
1 parent f93b914 commit 6c24c0e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function __construct(
public function current()
{
if (null === $this->currentSelect) {
$this->isValid = ($this->currentOffset + $this->batchSize) <= $this->totalItemCount;
$this->isValid = $this->currentOffset < $this->totalItemCount;
$this->currentSelect = $this->initSelectObject();
}
return $this->currentSelect;
Expand Down Expand Up @@ -144,7 +144,7 @@ public function next()
if (null === $this->currentSelect) {
$this->current();
}
$this->isValid = ($this->batchSize + $this->currentOffset) <= $this->totalItemCount;
$this->isValid = $this->currentOffset < $this->totalItemCount;
$select = $this->initSelectObject();
if ($this->isValid) {
$this->iteration++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@ public function testIterations()
$iterations++;
}

$this->assertEquals(10, $iterations);
$this->assertEquals(11, $iterations);
}
}

0 comments on commit 6c24c0e

Please sign in to comment.