Skip to content

Commit f4ff765

Browse files
committed
Fix tests for MongoDB 3.0.0
1 parent dce9ada commit f4ff765

File tree

3 files changed

+13
-40
lines changed

3 files changed

+13
-40
lines changed

tests/replicaset/writeconcern-error.phpt

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $w = new MongoDB\Driver\WriteConcern(30, 100);
1616
try {
1717
$retval = $manager->executeBulkWrite(NS, $bulk, $w);
1818
} catch(MongoDB\Driver\BulkWriteException $e) {
19-
printWriteResult($e->getWriteResult());
19+
printWriteResult($e->getWriteResult(), false);
2020
}
2121
?>
2222
===DONE===
@@ -28,21 +28,5 @@ matchedCount: 0
2828
modifiedCount: 0
2929
upsertedCount: 0
3030
deletedCount: 0
31-
object(MongoDB\Driver\WriteConcernError)#%d (%d) {
32-
["message"]=>
33-
string(33) "waiting for replication timed out"
34-
["code"]=>
35-
int(64)
36-
["info"]=>
37-
array(1) {
38-
["wtimeout"]=>
39-
bool(true)
40-
}
41-
}
42-
writeConcernError.message: waiting for replication timed out
43-
writeConcernError.code: 64
44-
writeConcernError.info: array(1) {
45-
["wtimeout"]=>
46-
bool(true)
47-
}
31+
writeConcernError: %s (%d)
4832
===DONE===

tests/replicaset/writeconcernerror-0001.phpt

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ $bulk->delete(array("my" => "value", "foo" => "bar"), array("limit" => 1));
1818

1919
$bulk->update(array("foo" => "bar"), array('$set' => array("foo" => "baz")), array("limit" => 1, "upsert" => 0));
2020

21-
$w = new MongoDB\Driver\WriteConcern(30, 100);
21+
$w = new MongoDB\Driver\WriteConcern(30);
2222
try {
2323
$retval = $manager->executeBulkWrite(NS, $bulk, $w);
2424
} catch(MongoDB\Driver\BulkWriteException $e) {
25-
printWriteResult($e->getWriteResult());
25+
printWriteResult($e->getWriteResult(), false);
2626
}
2727
?>
2828
===DONE===
@@ -34,21 +34,5 @@ matchedCount: 1
3434
modifiedCount: 1
3535
upsertedCount: 0
3636
deletedCount: 1
37-
object(MongoDB\Driver\WriteConcernError)#%d (%d) {
38-
["message"]=>
39-
string(33) "waiting for replication timed out"
40-
["code"]=>
41-
int(64)
42-
["info"]=>
43-
array(1) {
44-
["wtimeout"]=>
45-
bool(true)
46-
}
47-
}
48-
writeConcernError.message: waiting for replication timed out
49-
writeConcernError.code: 64
50-
writeConcernError.info: array(1) {
51-
["wtimeout"]=>
52-
bool(true)
53-
}
37+
writeConcernError: %s (%d)
5438
===DONE===

tests/utils/tools.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function printServer(MongoDB\Driver\Server $server)
112112
printf("server: %s:%d\n", $server->getHost(), $server->getPort());
113113
}
114114

115-
function printWriteResult(MongoDB\Driver\WriteResult $result)
115+
function printWriteResult(MongoDB\Driver\WriteResult $result, $details = true)
116116
{
117117
printServer($result->getServer());
118118

@@ -128,16 +128,21 @@ function printWriteResult(MongoDB\Driver\WriteResult $result)
128128
}
129129

130130
$writeConcernError = $result->getWriteConcernError();
131-
printWriteConcernError($writeConcernError ? $writeConcernError : null);
131+
printWriteConcernError($writeConcernError ? $writeConcernError : null, $details);
132132

133133
foreach ($result->getWriteErrors() as $writeError) {
134134
printWriteError($writeError);
135135
}
136136
}
137137

138-
function printWriteConcernError(MongoDB\Driver\WriteConcernError $error = null)
138+
function printWriteConcernError(MongoDB\Driver\WriteConcernError $error = null, $details)
139139
{
140140
if ($error) {
141+
/* This stuff is generated by the server, no need for us to test it */
142+
if (!$details) {
143+
printf("writeConcernError: %s (%d)\n", $error->getMessage(), $error->getCode());
144+
return;
145+
}
141146
var_dump($error);
142147
printf("writeConcernError.message: %s\n", $error->getMessage());
143148
printf("writeConcernError.code: %d\n", $error->getCode());

0 commit comments

Comments
 (0)