Skip to content

Commit 8944baa

Browse files
committed
Check exception messages
1 parent 695ddcc commit 8944baa

10 files changed

+40
-40
lines changed

tests/manager/manager-executeBulkWrite-012.phpt

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

2424
$result = $manager->executeBulkWrite(NS, $bulk, $options);
2525
var_dump($result->isAcknowledged());
26-
var_dump($result->getInsertedCount());
26+
if ($result->isAcknowledged()) {
27+
var_dump($result->getInsertedCount());
28+
}
2729
}
2830

2931
?>
3032
===DONE===
3133
<?php exit(0); ?>
3234
--EXPECTF--
3335
bool(false)
34-
35-
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
36-
NULL
3736
bool(true)
3837
int(1)
3938
bool(true)

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/server/server-executeBulkWrite-003.phpt

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

2121
$result = $server->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern($wc));
2222
var_dump($result->isAcknowledged());
23-
var_dump($result->getInsertedCount());
23+
if ($result->isAcknowledged()) {
24+
var_dump($result->getInsertedCount());
25+
}
2426
}
2527

2628
?>
2729
===DONE===
2830
<?php exit(0); ?>
2931
--EXPECTF--
3032
bool(false)
31-
32-
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
33-
NULL
3433
bool(true)
3534
int(1)
3635
bool(true)

tests/server/server-executeBulkWrite-005.phpt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ foreach ($writeConcerns as $wc) {
2525

2626
$result = $server->executeBulkWrite('local.' . COLLECTION_NAME, $bulk, new MongoDB\Driver\WriteConcern($wc));
2727
var_dump($result->isAcknowledged());
28-
var_dump($result->getInsertedCount());
28+
if ($result->isAcknowledged()) {
29+
var_dump($result->getInsertedCount());
30+
}
2931
}
3032

3133
$bulk = new MongoDB\Driver\BulkWrite();
@@ -37,9 +39,6 @@ $server->executeBulkWrite('local.' . COLLECTION_NAME, $bulk);
3739
<?php exit(0); ?>
3840
--EXPECTF--
3941
bool(false)
40-
41-
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
42-
NULL
4342
bool(true)
4443
int(1)
4544
===DONE===

tests/server/server-executeBulkWrite-006.phpt

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

2525
$result = $server->executeBulkWrite(NS, $bulk, $options);
2626
var_dump($result->isAcknowledged());
27-
var_dump($result->getInsertedCount());
27+
if ($result->isAcknowledged()) {
28+
var_dump($result->getInsertedCount());
29+
}
2830
}
2931

3032
?>
3133
===DONE===
3234
<?php exit(0); ?>
3335
--EXPECTF--
3436
bool(false)
35-
36-
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
37-
NULL
3837
bool(true)
3938
int(1)
4039
bool(true)

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)