Skip to content

Commit

Permalink
Check exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Sep 24, 2024
1 parent 695ddcc commit 8944baa
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 40 deletions.
7 changes: 3 additions & 4 deletions tests/manager/manager-executeBulkWrite-012.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@ foreach ($writeConcerns as $wc) {

$result = $manager->executeBulkWrite(NS, $bulk, $options);
var_dump($result->isAcknowledged());
var_dump($result->getInsertedCount());
if ($result->isAcknowledged()) {
var_dump($result->getInsertedCount());
}
}

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
bool(false)

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
NULL
bool(true)
int(1)
bool(true)
Expand Down
7 changes: 3 additions & 4 deletions tests/server/server-executeBulkWrite-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@ foreach ($writeConcerns as $writeConcern) {

$result = $primary->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern($writeConcern));
var_dump($result->isAcknowledged());
var_dump($result->getInsertedCount());
if ($result->isAcknowledged()) {
var_dump($result->getInsertedCount());
}
}

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
bool(false)

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
NULL
bool(true)
int(1)
===DONE===
7 changes: 3 additions & 4 deletions tests/server/server-executeBulkWrite-003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ foreach ($writeConcerns as $wc) {

$result = $server->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern($wc));
var_dump($result->isAcknowledged());
var_dump($result->getInsertedCount());
if ($result->isAcknowledged()) {
var_dump($result->getInsertedCount());
}
}

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
bool(false)

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
NULL
bool(true)
int(1)
bool(true)
Expand Down
7 changes: 3 additions & 4 deletions tests/server/server-executeBulkWrite-005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ foreach ($writeConcerns as $wc) {

$result = $server->executeBulkWrite('local.' . COLLECTION_NAME, $bulk, new MongoDB\Driver\WriteConcern($wc));
var_dump($result->isAcknowledged());
var_dump($result->getInsertedCount());
if ($result->isAcknowledged()) {
var_dump($result->getInsertedCount());
}
}

$bulk = new MongoDB\Driver\BulkWrite();
Expand All @@ -37,9 +39,6 @@ $server->executeBulkWrite('local.' . COLLECTION_NAME, $bulk);
<?php exit(0); ?>
--EXPECTF--
bool(false)

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
NULL
bool(true)
int(1)
===DONE===
7 changes: 3 additions & 4 deletions tests/server/server-executeBulkWrite-006.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ foreach ($writeConcerns as $wc) {

$result = $server->executeBulkWrite(NS, $bulk, $options);
var_dump($result->isAcknowledged());
var_dump($result->getInsertedCount());
if ($result->isAcknowledged()) {
var_dump($result->getInsertedCount());
}
}

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
bool(false)

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
NULL
bool(true)
int(1)
bool(true)
Expand Down
9 changes: 5 additions & 4 deletions tests/writeResult/writeresult-getdeletedcount-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ $bulk->delete(['x' => 1]);

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

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

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
OK: Got MongoDB\Driver\Exception\LogicException thrown from getDeletedCount
--EXPECT--
OK: Got MongoDB\Driver\Exception\LogicException
MongoDB\Driver\WriteResult::getDeletedCount() should not be called for an unacknowledged write result
===DONE===
9 changes: 5 additions & 4 deletions tests/writeResult/writeresult-getinsertedcount-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ $bulk->delete(['x' => 1]);

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

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

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
OK: Got MongoDB\Driver\Exception\LogicException thrown from getInsertedCount
--EXPECT--
OK: Got MongoDB\Driver\Exception\LogicException
MongoDB\Driver\WriteResult::getInsertedCount() should not be called for an unacknowledged write result
===DONE===
9 changes: 5 additions & 4 deletions tests/writeResult/writeresult-getmatchedcount-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ $bulk->delete(['x' => 1]);

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

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

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
OK: Got MongoDB\Driver\Exception\LogicException thrown from getMatchedCount
--EXPECT--
OK: Got MongoDB\Driver\Exception\LogicException
MongoDB\Driver\WriteResult::getMatchedCount() should not be called for an unacknowledged write result
===DONE===
9 changes: 5 additions & 4 deletions tests/writeResult/writeresult-getmodifiedcount-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ $bulk->delete(['x' => 1]);

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

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

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
OK: Got MongoDB\Driver\Exception\LogicException thrown from getModifiedCount
--EXPECT--
OK: Got MongoDB\Driver\Exception\LogicException
MongoDB\Driver\WriteResult::getModifiedCount() should not be called for an unacknowledged write result
===DONE===
9 changes: 5 additions & 4 deletions tests/writeResult/writeresult-getupsertedcount-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ $bulk->delete(['x' => 1]);

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

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

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

0 comments on commit 8944baa

Please sign in to comment.