Skip to content

Commit bb776aa

Browse files
author
fso
committed
Add cursor support
1 parent 84cd241 commit bb776aa

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/QueryBuilderTest.php

+21
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use Illuminate\Support\Facades\Date;
55
use Illuminate\Support\Facades\DB;
6+
use Illuminate\Support\LazyCollection;
67
use Jenssegers\Mongodb\Collection;
78
use Jenssegers\Mongodb\Query\Builder;
89
use MongoDB\BSON\ObjectId;
@@ -759,4 +760,24 @@ public function testHintOptions()
759760
$this->assertEquals('spork', $results[1]['name']);
760761
$this->assertEquals('fork', $results[0]['name']);
761762
}
763+
764+
public function testCursor()
765+
{
766+
$data = [
767+
['name' => 'fork', 'tags' => ['sharp', 'pointy']],
768+
['name' => 'spork', 'tags' => ['sharp', 'pointy', 'round', 'bowl']],
769+
['name' => 'spoon', 'tags' => ['round', 'bowl']],
770+
];
771+
DB::collection('items')->insert($data);
772+
773+
$results = DB::collection('items')->orderBy('_id', 'asc')->cursor();
774+
775+
$this->assertInstanceOf(LazyCollection::class, $results);
776+
$i = 0;
777+
foreach ($results as $result) {
778+
$this->assertEquals($data[$i]['name'], $result['name']);
779+
$i++;
780+
}
781+
782+
}
762783
}

0 commit comments

Comments
 (0)