Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

HHVM-193: executeBulkWrite() should throw InvalidArgumentException for empty BulkWrite #77

Merged
merged 1 commit into from
Mar 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/MongoDBDriverManager_executeBulkWrite-error-001.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
MongoDB\Driver\Manager::executeBulkWrite() update write error
--FILE--
<?php
include dirname(__FILE__) . '/utils.inc';

$m = new MongoDB\Driver\Manager("mongodb://localhost:27017");
cleanup( $m );

$bw = new MongoDB\Driver\BulkWrite();

try {
$result = $m->executeBulkWrite( 'demo.test', $bw );
} catch ( Exception $e ) {
echo get_class( $e ), "\n";
echo $e->getMessage(), "\n";
}

?>
--EXPECT--
MongoDB\Driver\Exception\InvalidArgumentException
Cannot execute an empty BulkWrite
4 changes: 3 additions & 1 deletion utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,14 @@ HPHP::Object Utils::throwExceptionFromBsonError(bson_error_t *error)
case MONGOC_ERROR_BSON_INVALID:
case MONGOC_ERROR_MATCHER_INVALID:
case MONGOC_ERROR_NAMESPACE_INVALID:
case MONGOC_ERROR_COMMAND_INVALID_ARG:
case MONGOC_ERROR_COLLECTION_INSERT_FAILED:
case MONGOC_ERROR_GRIDFS_INVALID_FILENAME:
case MONGOC_ERROR_QUERY_COMMAND_NOT_FOUND:
case MONGOC_ERROR_QUERY_NOT_TAILABLE:
return Utils::CreateAndConstruct(s_MongoDriverExceptionRuntimeException_className, HPHP::Variant(error->message), HPHP::Variant((uint64_t) error->code));

case MONGOC_ERROR_COMMAND_INVALID_ARG:
return Utils::CreateAndConstruct(s_MongoDriverExceptionInvalidArgumentException_className, HPHP::Variant("Cannot execute an empty BulkWrite"), HPHP::Variant((uint64_t) 0));
}
switch (error->domain) {
case MONGOC_ERROR_CLIENT:
Expand Down