File tree Expand file tree Collapse file tree 1 file changed +61
-0
lines changed
Expand file tree Collapse file tree 1 file changed +61
-0
lines changed Original file line number Diff line number Diff line change 1+ --TEST--
2+ MongoDB\Driver\Cursor get_iterator handler does not yield multiple iterators (toArray())
3+ --SKIPIF--
4+ <?php require __DIR__ . "/../utils/basic-skipif.inc " ; CLEANUP (STANDALONE ) ?>
5+ --FILE--
6+ <?php
7+ require_once __DIR__ . "/../utils/basic.inc " ;
8+
9+ $ manager = new MongoDB \Driver \Manager (STANDALONE );
10+
11+ $ bulkWrite = new MongoDB \Driver \BulkWrite ;
12+
13+ for ($ i = 0 ; $ i < 3 ; $ i ++) {
14+ $ bulkWrite ->insert (array ('_id ' => $ i ));
15+ }
16+
17+ $ writeResult = $ manager ->executeBulkWrite (NS , $ bulkWrite );
18+ printf ("Inserted: %d \n" , $ writeResult ->getInsertedCount ());
19+
20+ $ cursor = $ manager ->executeQuery (NS , new MongoDB \Driver \Query (array ()));
21+
22+ echo "\nFirst Cursor::toArray(): \n" ;
23+
24+ var_dump ($ cursor ->toArray ());
25+
26+ echo "\nSecond Cursor::toArray(): \n" ;
27+
28+ try {
29+ var_dump ($ cursor ->toArray ());
30+ } catch (MongoDB \Driver \Exception \LogicException $ e ) {
31+ printf ("LogicException: %s \n" , $ e ->getMessage ());
32+ }
33+
34+ ?>
35+ ===DONE===
36+ <?php exit (0 ); ?>
37+ --EXPECTF--
38+ Inserted: 3
39+
40+ First Cursor::toArray():
41+ array(3) {
42+ [0]=>
43+ array(1) {
44+ ["_id"]=>
45+ int(0)
46+ }
47+ [1]=>
48+ array(1) {
49+ ["_id"]=>
50+ int(1)
51+ }
52+ [2]=>
53+ array(1) {
54+ ["_id"]=>
55+ int(2)
56+ }
57+ }
58+
59+ Second Cursor::toArray():
60+ LogicException: Cursors cannot yield multiple iterators
61+ ===DONE===
You can’t perform that action at this time.
0 commit comments