Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Zend\Db\ResultSet: added buffer unit tests

  • Loading branch information...
commit d4d4ce40dedac54bebcc746da7170715879b1901 1 parent d91cdb6
@ralphschindler authored
Showing with 23 additions and 0 deletions.
  1. +23 −0 tests/ZendTest/Db/ResultSet/ResultSetTest.php
View
23 tests/ZendTest/Db/ResultSet/ResultSetTest.php
@@ -191,4 +191,27 @@ public function testToArrayCreatesArrayOfArraysRepresentingRows()
$test = $this->resultSet->toArray();
$this->assertEquals($dataSource->getArrayCopy(), $test, var_export($test, 1));
}
+
+ public function testBufferingCallsDatasourceCurrentOnce()
+ {
+ $mockResult = $this->getMock('Zend\Db\Adapter\Driver\ResultInterface');
+ $mockResult->expects($this->once())->method('current')->will($this->returnValue(array('foo' => 'bar')));
+
+ $this->resultSet->initialize($mockResult);
+ $this->resultSet->buffer();
+ $this->resultSet->current();
+
+ // assertion above will fail if this calls datasource current
+ $this->resultSet->current();
+ }
+
+ public function testCallingBufferAfterIterationThrowsException()
+ {
+ $this->resultSet->initialize($this->getMock('Zend\Db\Adapter\Driver\ResultInterface'));
+ $this->resultSet->current();
+
+ $this->setExpectedException('Zend\Db\ResultSet\Exception\RuntimeException', 'Buffering must be enabled before iteration is started');
+ $this->resultSet->buffer();
+ }
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.