File tree Expand file tree Collapse file tree 4 files changed +162
-0
lines changed Expand file tree Collapse file tree 4 files changed +162
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ MongoDB\Driver\Cursor query result iteration with batchSize requiring getmore with full batches
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 < 6 ; $ 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 (), array ('batchSize ' => 2 )));
21
+
22
+ foreach ($ cursor as $ i => $ document ) {
23
+ printf ("%d => {_id: %d} \n" , $ i , $ document ['_id ' ]);
24
+ }
25
+
26
+ ?>
27
+ ===DONE===
28
+ <?php exit (0 ); ?>
29
+ --EXPECT--
30
+ Inserted: 6
31
+ 0 => {_id: 0}
32
+ 1 => {_id: 1}
33
+ 2 => {_id: 2}
34
+ 3 => {_id: 3}
35
+ 4 => {_id: 4}
36
+ 5 => {_id: 5}
37
+ ===DONE===
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ MongoDB\Driver\Cursor query result iteration with batchSize requiring getmore with non-full batches
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 < 5 ; $ 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 (), array ('batchSize ' => 2 )));
21
+
22
+ foreach ($ cursor as $ i => $ document ) {
23
+ printf ("%d => {_id: %d} \n" , $ i , $ document ['_id ' ]);
24
+ }
25
+
26
+ ?>
27
+ ===DONE===
28
+ <?php exit (0 ); ?>
29
+ --EXPECT--
30
+ Inserted: 5
31
+ 0 => {_id: 0}
32
+ 1 => {_id: 1}
33
+ 2 => {_id: 2}
34
+ 3 => {_id: 3}
35
+ 4 => {_id: 4}
36
+ ===DONE===
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ MongoDB\Driver\Cursor command result iteration with batchSize requiring getmore with full batches
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 < 6 ; $ i ++) {
14
+ $ bulkWrite ->insert (array ('_id ' => $ i ));
15
+ }
16
+
17
+ $ writeResult = $ manager ->executeBulkWrite (NS , $ bulkWrite );
18
+ printf ("Inserted: %d \n" , $ writeResult ->getInsertedCount ());
19
+
20
+ $ command = new MongoDB \Driver \Command (array (
21
+ 'aggregate ' => COLLECTION_NAME ,
22
+ 'pipeline ' => array (
23
+ array ('$match ' => new stdClass ),
24
+ ),
25
+ 'cursor ' => array ('batchSize ' => 2 ),
26
+ ));
27
+
28
+ $ cursor = $ manager ->executeCommand (DATABASE_NAME , $ command );
29
+
30
+ foreach ($ cursor as $ i => $ document ) {
31
+ printf ("%d => {_id: %d} \n" , $ i , $ document ['_id ' ]);
32
+ }
33
+
34
+ ?>
35
+ ===DONE===
36
+ <?php exit (0 ); ?>
37
+ --EXPECT--
38
+ Inserted: 6
39
+ 0 => {_id: 0}
40
+ 1 => {_id: 1}
41
+ 2 => {_id: 2}
42
+ 3 => {_id: 3}
43
+ 4 => {_id: 4}
44
+ 5 => {_id: 5}
45
+ ===DONE===
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ MongoDB\Driver\Cursor command result iteration with batchSize requiring getmore with non-full batches
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 < 5 ; $ i ++) {
14
+ $ bulkWrite ->insert (array ('_id ' => $ i ));
15
+ }
16
+
17
+ $ writeResult = $ manager ->executeBulkWrite (NS , $ bulkWrite );
18
+ printf ("Inserted: %d \n" , $ writeResult ->getInsertedCount ());
19
+
20
+ $ command = new MongoDB \Driver \Command (array (
21
+ 'aggregate ' => COLLECTION_NAME ,
22
+ 'pipeline ' => array (
23
+ array ('$match ' => new stdClass ),
24
+ ),
25
+ 'cursor ' => array ('batchSize ' => 2 ),
26
+ ));
27
+
28
+ $ cursor = $ manager ->executeCommand (DATABASE_NAME , $ command );
29
+
30
+ foreach ($ cursor as $ i => $ document ) {
31
+ printf ("%d => {_id: %d} \n" , $ i , $ document ['_id ' ]);
32
+ }
33
+
34
+ ?>
35
+ ===DONE===
36
+ <?php exit (0 ); ?>
37
+ --EXPECT--
38
+ Inserted: 5
39
+ 0 => {_id: 0}
40
+ 1 => {_id: 1}
41
+ 2 => {_id: 2}
42
+ 3 => {_id: 3}
43
+ 4 => {_id: 4}
44
+ ===DONE===
You can’t perform that action at this time.
0 commit comments