Skip to content

Commit 8a89718

Browse files
committed
Check exception messages
1 parent 695ddcc commit 8a89718

6 files changed

+28
-24
lines changed

tests/server/server-executeBulkWrite-002.phpt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,16 @@ foreach ($writeConcerns as $writeConcern) {
1919

2020
$result = $primary->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern($writeConcern));
2121
var_dump($result->isAcknowledged());
22-
var_dump($result->getInsertedCount());
22+
if ($result->isAcknowledged()) {
23+
var_dump($result->getInsertedCount());
24+
}
2325
}
2426

2527
?>
2628
===DONE===
2729
<?php exit(0); ?>
2830
--EXPECTF--
2931
bool(false)
30-
31-
Deprecated: MongoDB\Driver\WriteResult::getInsertedCount(): Calling MongoDB\Driver\WriteResult::getInsertedCount() for an unacknowledged write is deprecated and will throw an exception in ext-mongodb 2.0 in %s
32-
NULL
3332
bool(true)
3433
int(1)
3534
===DONE===

tests/writeResult/writeresult-getdeletedcount-002.phpt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ $bulk->delete(['x' => 1]);
1919

2020
$result = $manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(0));
2121

22-
throws(function() use ($result) {
22+
echo throws(function() use ($result) {
2323
$result->getDeletedCount();
24-
}, MongoDB\Driver\Exception\LogicException::class, 'getDeletedCount');
24+
}, MongoDB\Driver\Exception\LogicException::class), "\n";
2525

2626
?>
2727
===DONE===
2828
<?php exit(0); ?>
29-
--EXPECTF--
30-
OK: Got MongoDB\Driver\Exception\LogicException thrown from getDeletedCount
29+
--EXPECT--
30+
OK: Got MongoDB\Driver\Exception\LogicException
31+
MongoDB\Driver\WriteResult::getDeletedCount() should not be called for an unacknowledged write result
3132
===DONE===

tests/writeResult/writeresult-getinsertedcount-002.phpt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ $bulk->delete(['x' => 1]);
1919

2020
$result = $manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(0));
2121

22-
throws(function() use ($result) {
22+
echo throws(function() use ($result) {
2323
$result->getInsertedCount();
24-
}, MongoDB\Driver\Exception\LogicException::class, 'getInsertedCount');
24+
}, MongoDB\Driver\Exception\LogicException::class), "\n";
2525

2626
?>
2727
===DONE===
2828
<?php exit(0); ?>
29-
--EXPECTF--
30-
OK: Got MongoDB\Driver\Exception\LogicException thrown from getInsertedCount
29+
--EXPECT--
30+
OK: Got MongoDB\Driver\Exception\LogicException
31+
MongoDB\Driver\WriteResult::getInsertedCount() should not be called for an unacknowledged write result
3132
===DONE===

tests/writeResult/writeresult-getmatchedcount-002.phpt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ $bulk->delete(['x' => 1]);
1919

2020
$result = $manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(0));
2121

22-
throws(function() use ($result) {
22+
echo throws(function() use ($result) {
2323
$result->getMatchedCount();
24-
}, MongoDB\Driver\Exception\LogicException::class, 'getMatchedCount');
24+
}, MongoDB\Driver\Exception\LogicException::class), "\n";
2525

2626
?>
2727
===DONE===
2828
<?php exit(0); ?>
29-
--EXPECTF--
30-
OK: Got MongoDB\Driver\Exception\LogicException thrown from getMatchedCount
29+
--EXPECT--
30+
OK: Got MongoDB\Driver\Exception\LogicException
31+
MongoDB\Driver\WriteResult::getMatchedCount() should not be called for an unacknowledged write result
3132
===DONE===

tests/writeResult/writeresult-getmodifiedcount-002.phpt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ $bulk->delete(['x' => 1]);
1919

2020
$result = $manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(0));
2121

22-
throws(function() use ($result) {
22+
echo throws(function() use ($result) {
2323
$result->getModifiedCount();
24-
}, MongoDB\Driver\Exception\LogicException::class, 'getModifiedCount');
24+
}, MongoDB\Driver\Exception\LogicException::class), "\n";
2525

2626
?>
2727
===DONE===
2828
<?php exit(0); ?>
29-
--EXPECTF--
30-
OK: Got MongoDB\Driver\Exception\LogicException thrown from getModifiedCount
29+
--EXPECT--
30+
OK: Got MongoDB\Driver\Exception\LogicException
31+
MongoDB\Driver\WriteResult::getModifiedCount() should not be called for an unacknowledged write result
3132
===DONE===

tests/writeResult/writeresult-getupsertedcount-002.phpt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ $bulk->delete(['x' => 1]);
1919

2020
$result = $manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(0));
2121

22-
throws(function() use ($result) {
22+
echo throws(function() use ($result) {
2323
$result->getUpsertedCount();
24-
}, MongoDB\Driver\Exception\LogicException::class, 'getUpsertedCount');
24+
}, MongoDB\Driver\Exception\LogicException::class), "\n";
2525

2626
?>
2727
===DONE===
2828
<?php exit(0); ?>
29-
--EXPECTF--
30-
OK: Got MongoDB\Driver\Exception\LogicException thrown from getUpsertedCount
29+
--EXPECT--
30+
OK: Got MongoDB\Driver\Exception\LogicException
31+
MongoDB\Driver\WriteResult::getUpsertedCount() should not be called for an unacknowledged write result
3132
===DONE===

0 commit comments

Comments
 (0)