Skip to content

Commit 51707d8

Browse files
committed
Merge pull request #217
2 parents 290cbf6 + 5b00e22 commit 51707d8

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
--TEST--
2+
MongoDB\Driver\Server::executeQuery() with negative limit returns a single batch
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+
$server = $manager->executeQuery(NS, new MongoDB\Driver\Query(array()))->getServer();
11+
12+
// load fixtures for test
13+
$bulk = new \MongoDB\Driver\BulkWrite();
14+
$bulk->insert(['_id' => 1, 'x' => 2, 'y' => 3]);
15+
$bulk->insert(['_id' => 2, 'x' => 3, 'y' => 4]);
16+
$bulk->insert(['_id' => 3, 'x' => 4, 'y' => 5]);
17+
$server->executeBulkWrite(NS, $bulk);
18+
19+
$query = new MongoDB\Driver\Query([], ['limit' => -2]);
20+
$cursor = $server->executeQuery(NS, $query);
21+
22+
var_dump($cursor instanceof MongoDB\Driver\Cursor);
23+
var_dump($server == $cursor->getServer());
24+
var_dump(iterator_to_array($cursor));
25+
26+
?>
27+
===DONE===
28+
<?php exit(0); ?>
29+
--EXPECTF--
30+
bool(true)
31+
bool(true)
32+
array(2) {
33+
[0]=>
34+
object(stdClass)#%d (3) {
35+
["_id"]=>
36+
int(1)
37+
["x"]=>
38+
int(2)
39+
["y"]=>
40+
int(3)
41+
}
42+
[1]=>
43+
object(stdClass)#%d (3) {
44+
["_id"]=>
45+
int(2)
46+
["x"]=>
47+
int(3)
48+
["y"]=>
49+
int(4)
50+
}
51+
}
52+
===DONE===

0 commit comments

Comments
 (0)