Explorar o código

Add unit test to capture issue #190 which is fixed in previous commit

Rob Williams %!s(int64=8) %!d(string=hai) anos
pai
achega
c976c05702
Modificáronse 1 ficheiros con 16 adicións e 0 borrados
  1. 16 0
      tests/Alcaeus/MongoDbAdapter/Mongo/MongoCursorTest.php

+ 16 - 0
tests/Alcaeus/MongoDbAdapter/Mongo/MongoCursorTest.php

@@ -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']);