forked from mongodb/mongo-php-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcursor-getmore-003.phpt
47 lines (39 loc) · 1.05 KB
/
cursor-getmore-003.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
--TEST--
MongoDB\Driver\Cursor command result iteration with batchSize requiring getmore with full batches
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php skip_if_not_live(); ?>
<?php skip_if_not_clean(); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
$manager = create_test_manager();
$bulkWrite = new MongoDB\Driver\BulkWrite;
for ($i = 0; $i < 6; $i++) {
$bulkWrite->insert(array('_id' => $i));
}
$writeResult = $manager->executeBulkWrite(NS, $bulkWrite);
printf("Inserted: %d\n", $writeResult->getInsertedCount());
$command = new MongoDB\Driver\Command(array(
'aggregate' => COLLECTION_NAME,
'pipeline' => array(
array('$match' => new stdClass),
),
'cursor' => array('batchSize' => 2),
));
$cursor = $manager->executeCommand(DATABASE_NAME, $command);
foreach ($cursor as $i => $document) {
printf("%d => {_id: %d}\n", $i, $document->_id);
}
?>
===DONE===
<?php exit(0); ?>
--EXPECT--
Inserted: 6
0 => {_id: 0}
1 => {_id: 1}
2 => {_id: 2}
3 => {_id: 3}
4 => {_id: 4}
5 => {_id: 5}
===DONE===