Skip to content

Commit 6e31d2f

Browse files
committed
Fix tests on 5.3 -- and use consistent db/collection
1 parent 41e0323 commit 6e31d2f

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

tests/bson/bson-ods-001.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ foreach($m->executeQuery(NS, $query) as $person) {
145145

146146
echo "-----\n";
147147

148-
$hartmann = $m->executeQuery(NS, $queryHartmann)->toArray()[0];
148+
$array = $m->executeQuery(NS, $queryHartmann)->toArray();
149+
$hartmann = $array[0];
149150
var_dump($hartmann->getName());
150151
$hartmann->setName("Dr. " . $hartmann->getName());
151152

tests/bson/bson-ods-002.phpt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ $m = new MongoDB\Driver\Manager(STANDALONE);
133133

134134
try {
135135
/* Drop the collection between runs */
136-
$dropcoll = new MongoDB\Driver\Command(array("drop" => "people"));
137-
$m->executeCommand("examples", $dropcoll);
136+
$dropcoll = new MongoDB\Driver\Command(array("drop" => COLLECTION_NAME));
137+
$m->executeCommand(DATABASE_NAME, $dropcoll);
138138
} catch(Exception $e) {}
139139

140140
$bulk = new MongoDB\Driver\BulkWrite;
@@ -179,7 +179,7 @@ $bulk->insert($lockman);
179179

180180

181181
/* Insert our fixtures in one bulk write operation */
182-
$m->executeBulkWrite("examples.people", $bulk);
182+
$m->executeBulkWrite(NS, $bulk);
183183

184184

185185

@@ -188,7 +188,7 @@ $m->executeBulkWrite("examples.people", $bulk);
188188
* converting them back into Person objects -- and the nested Address object!
189189
*/
190190
$query = new MongoDB\Driver\Query(array());
191-
foreach($m->executeQuery("examples.people", $query) as $person) {
191+
foreach($m->executeQuery(NS, $query) as $person) {
192192
echo $person->getName(), " has the following address(es):\n";
193193
foreach($person->getAddresses() as $address) {
194194
echo "\t", $address->getStreetAddress(), "\n";
@@ -201,17 +201,19 @@ echo "-----\n";
201201
/* Hartmann graduated with a doctorate and deserves a Dr. prefix */
202202
$hartmannFilter = array("username" => "hartmann");
203203
$queryHartmann = new MongoDB\Driver\Query($hartmannFilter);
204-
$hartmann = $m->executeQuery("examples.people", $queryHartmann)->toArray()[0];
204+
$array = $m->executeQuery(NS, $queryHartmann)->toArray();
205+
$hartmann = $array[0];
205206
$hartmann->setName("Dr. " . $hartmann->getName());
206207

207-
$retval = $m->executeUpdate("examples.people", $hartmannFilter, $hartmann);
208+
$retval = $m->executeUpdate(NS, $hartmannFilter, $hartmann);
208209
printf("Updated %d person (%s)\n", $retval->getModifiedCount(), $hartmann->getName());
209210

210211
$queryAll = new MongoDB\Driver\Query(array());
211-
$all = $m->executeQuery("examples.people", $queryAll)->toArray();
212+
$all = $m->executeQuery(NS, $queryAll)->toArray();
212213
foreach($all as $person) {
213214
if ($person->getName() == "Dr. Hartmann Dedrick") {
214-
var_dump($person->toArray()["username"]);
215+
$array = $person->toArray();
216+
var_dump($array["username"]);
215217
var_dump($person->getCreatedDateTime()->format(DATE_RSS));
216218
var_dump($person->getLastModifiedDateTime()->format(DATE_RSS));
217219
}

0 commit comments

Comments
 (0)