Skip to content

Commit b54a8bf

Browse files
committed
PHPC-450: Split query tests for OP_QUERY and find command
This also entails a change to done/end_of_event cursor field assertions. These are internal libmongoc cursor fields and their values aren't relevant to the tests. In the future, we may consider removing them from the Cursor's dump output.
1 parent 8e67243 commit b54a8bf

File tree

6 files changed

+496
-13
lines changed

6 files changed

+496
-13
lines changed

tests/manager/manager-executeQuery-001.phpt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
--TEST--
2-
MongoDB\Driver\Manager::executeQuery() one document
2+
MongoDB\Driver\Manager::executeQuery() one document (OP_QUERY)
33
--SKIPIF--
4-
<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?>
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php NEEDS("STANDALONE_30"); CLEANUP(STANDALONE_30); ?>
56
--FILE--
67
<?php
78
require_once __DIR__ . "/../utils/basic.inc";
89

9-
$manager = new MongoDB\Driver\Manager(STANDALONE);
10+
$manager = new MongoDB\Driver\Manager(STANDALONE_30);
1011

1112
// load fixtures for test
1213
$bulk = new MongoDB\Driver\BulkWrite();
@@ -52,15 +53,15 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
5253
["has_fields"]=>
5354
bool(true)
5455
["query"]=>
55-
object(stdClass)#%d (1) {
56+
object(stdClass)#%d (%d) {
5657
["$query"]=>
5758
object(stdClass)#%d (%d) {
5859
["x"]=>
5960
int(3)
6061
}
6162
}
6263
["fields"]=>
63-
object(stdClass)#%d (1) {
64+
object(stdClass)#%d (%d) {
6465
["y"]=>
6566
int(1)
6667
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
--TEST--
2+
MongoDB\Driver\Manager::executeQuery() one document (find command)
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+
// load fixtures for test
12+
$bulk = new MongoDB\Driver\BulkWrite();
13+
$bulk->insert(array('_id' => 1, 'x' => 2, 'y' => 3));
14+
$bulk->insert(array('_id' => 2, 'x' => 3, 'y' => 4));
15+
$bulk->insert(array('_id' => 3, 'x' => 4, 'y' => 5));
16+
$manager->executeBulkWrite(NS, $bulk);
17+
18+
$query = new MongoDB\Driver\Query(array('x' => 3), array('projection' => array('y' => 1)));
19+
$qr = $manager->executeQuery(NS, $query);
20+
21+
var_dump($qr instanceof MongoDB\Driver\Cursor);
22+
var_dump($qr);
23+
24+
$server = $qr->getServer();
25+
26+
var_dump($server instanceof MongoDB\Driver\Server);
27+
var_dump($server->getHost());
28+
var_dump($server->getPort());
29+
30+
var_dump(iterator_to_array($qr));
31+
32+
?>
33+
===DONE===
34+
<?php exit(0); ?>
35+
--EXPECTF--
36+
bool(true)
37+
object(MongoDB\Driver\Cursor)#%d (%d) {
38+
["cursor"]=>
39+
array(%d) {
40+
["stamp"]=>
41+
int(0)
42+
["is_command"]=>
43+
bool(false)
44+
["sent"]=>
45+
bool(true)
46+
["done"]=>
47+
bool(false)
48+
["end_of_event"]=>
49+
bool(false)
50+
["in_exhaust"]=>
51+
bool(false)
52+
["has_fields"]=>
53+
bool(true)
54+
["query"]=>
55+
object(stdClass)#%d (%d) {
56+
["find"]=>
57+
string(%d) "%s"
58+
["filter"]=>
59+
object(stdClass)#%d (%d) {
60+
["x"]=>
61+
int(3)
62+
}
63+
["projection"]=>
64+
object(stdClass)#%d (%d) {
65+
["y"]=>
66+
int(1)
67+
}
68+
}
69+
["fields"]=>
70+
object(stdClass)#%d (%d) {
71+
["y"]=>
72+
int(1)
73+
}
74+
["read_preference"]=>
75+
array(2) {
76+
["mode"]=>
77+
int(1)
78+
["tags"]=>
79+
array(0) {
80+
}
81+
}
82+
["flags"]=>
83+
int(0)
84+
["skip"]=>
85+
int(0)
86+
["limit"]=>
87+
int(0)
88+
["count"]=>
89+
int(1)
90+
["batch_size"]=>
91+
int(0)
92+
["ns"]=>
93+
string(39) "phongo.manager_manager_executeQuery_002"
94+
["current_doc"]=>
95+
object(stdClass)#%d (2) {
96+
["_id"]=>
97+
int(2)
98+
["y"]=>
99+
int(4)
100+
}
101+
}
102+
["server_id"]=>
103+
int(1)
104+
}
105+
bool(true)
106+
string(%d) "%s"
107+
int(%d)
108+
array(1) {
109+
[0]=>
110+
object(stdClass)#%d (2) {
111+
["_id"]=>
112+
int(2)
113+
["y"]=>
114+
int(4)
115+
}
116+
}
117+
===DONE===

tests/readPreference/bug0146.phpt renamed to tests/readPreference/bug0146-001.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
--TEST--
2-
PHPC-146: ReadPreference primaryPreferred and secondary swapped
2+
PHPC-146: ReadPreference primaryPreferred and secondary swapped (OP_QUERY)
33
--SKIPIF--
4-
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; NEEDS("STANDALONE_30"); ?>
55
--FILE--
66
<?php
77
require_once __DIR__ . "/../utils/basic.inc";
88

9-
$manager = new MongoDB\Driver\Manager(STANDALONE);
9+
$manager = new MongoDB\Driver\Manager(STANDALONE_30);
1010

1111
$bulk = new MongoDB\Driver\BulkWrite();
1212
$bulk->insert(array('my' => 'document'));
@@ -48,7 +48,7 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
4848
["has_fields"]=>
4949
bool(false)
5050
["query"]=>
51-
object(stdClass)#%d (1) {
51+
object(stdClass)#%d (%d) {
5252
["$query"]=>
5353
object(stdClass)#%d (%d) {
5454
["my"]=>

0 commit comments

Comments
 (0)