|
|
@@ -28,6 +28,22 @@ class MongoCursorTest extends TestCase
|
|
|
$cursor = $collection->find(['foo' => 'bar']);
|
|
|
$this->assertCount(2, $cursor);
|
|
|
|
|
|
+ $this->assertCursorIteration($cursor);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testCursorHandlesHasNextBeforeIteration()
|
|
|
+ {
|
|
|
+ $this->prepareData();
|
|
|
+
|
|
|
+ $collection = $this->getCollection();
|
|
|
+ $cursor = $collection->find(['foo' => 'bar']);
|
|
|
+ $this->assertTrue($cursor->hasNext());
|
|
|
+
|
|
|
+ $this->assertCursorIteration($cursor);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function assertCursorIteration($cursor)
|
|
|
+ {
|
|
|
$iterated = 0;
|
|
|
foreach ($cursor as $key => $item) {
|
|
|
$this->assertSame($iterated, $cursor->info()['at']);
|