Skip to content

Commit

Permalink
test multiple iterations of buffered ResultSet
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchreiber authored and Ocramius committed Jan 3, 2015
1 parent 6bf0b23 commit 01af6ce
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/ZendTest/Db/ResultSet/AbstractResultSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,34 @@ public function testToArray()
$resultSet->toArray()
);
}

/**
* Test multiple iterations with buffer
*/
public function testBufferIterations()
{
$resultSet = $this->getMockForAbstractClass('Zend\Db\ResultSet\AbstractResultSet');
$resultSet->initialize(new \ArrayIterator(array(
array('id' => 1, 'name' => 'one'),
array('id' => 2, 'name' => 'two'),
array('id' => 3, 'name' => 'three'),
)));
$resultSet->buffer();

$data = $resultSet->current();
$this->assertEquals(1, $data['id']);
$resultSet->next();
$data = $resultSet->current();
$this->assertEquals(2, $data['id']);

$resultSet->rewind();
$data = $resultSet->current();
$this->assertEquals(1, $data['id']);
$resultSet->next();
$data = $resultSet->current();
$this->assertEquals(2, $data['id']);
$resultSet->next();
$data = $resultSet->current();
$this->assertEquals(3, $data['id']);
}
}

0 comments on commit 01af6ce

Please sign in to comment.