public function testShouldRewindACursorThatHasAlreadyBeenInitialized()
{
// Arrange
$collection = m::mock(Collection::class);
$driverCursor = m::mock(IteratorIterator::class);
$cursor = $this->getCursor(null, $collection, 'find', [[]], $driverCursor);
$this->setProtected($cursor, 'position', 10);
// Act
$driverCursor->shouldReceive('rewind')->twice()->andReturnUsing(function () use($cursor) {
if ($this->getProtected($cursor, 'cursor')) {
throw new LogicException('Cursor already initialized', 1);
}
});
// Assert
$cursor->rewind();
$this->assertAttributeEquals(0, 'position', $cursor);
}