mirror of
https://github.com/macintoshplus/mongo-php-driver.git
synced 2026-04-01 22:02:23 +02:00
This changes WriteResult to encapsulate a bson_t, which is populated by mongoc_bulk_operation_execute(), instead of the private mongoc_write_result_t struct. This entailed significant changes to the WriteResult debug handler, so new tests have been added for it. With phongo_execute_write() modified to populate a bson_t reply, we also changed error handling to pull a BulkWriteException message from bson_error_t (PHPC-626). That change required several error tests to be modified for the new message format.
49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
--TEST--
|
|
MongoDB\Driver\Manager::executeBulkWrite() insert write error
|
|
--SKIPIF--
|
|
<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?>
|
|
--FILE--
|
|
<?php
|
|
require_once __DIR__ . "/../utils/basic.inc";
|
|
|
|
$manager = new MongoDB\Driver\Manager(STANDALONE);
|
|
|
|
$bulk = new MongoDB\Driver\BulkWrite();
|
|
$bulk->insert(['$foo' => 1]);
|
|
|
|
try {
|
|
$manager->executeBulkWrite(NS, $bulk);
|
|
} catch (MongoDB\Driver\Exception\BulkWriteException $e) {
|
|
printf("BulkWriteException: %s\n", $e->getMessage());
|
|
|
|
echo "\n===> WriteResult\n";
|
|
printWriteResult($e->getWriteResult());
|
|
}
|
|
|
|
?>
|
|
===DONE===
|
|
<?php exit(0); ?>
|
|
--EXPECTF--
|
|
BulkWriteException: Document can't have $ prefixed field names: $foo
|
|
|
|
===> WriteResult
|
|
server: %s:%d
|
|
insertedCount: 0
|
|
matchedCount: 0
|
|
modifiedCount: 0
|
|
upsertedCount: 0
|
|
deletedCount: 0
|
|
object(MongoDB\Driver\WriteError)#%d (%d) {
|
|
["message"]=>
|
|
string(48) "Document can't have $ prefixed field names: $foo"
|
|
["code"]=>
|
|
int(2)
|
|
["index"]=>
|
|
int(0)
|
|
["info"]=>
|
|
NULL
|
|
}
|
|
writeError[0].message: Document can't have $ prefixed field names: $foo
|
|
writeError[0].code: 2
|
|
===DONE===
|