Files
mongo-php-driver/tests/standalone/manager-executeWriteBatch-003.phpt
T
Hannes Magnusson 554c4105d1 Do not test the error messages from the server
The error message vary depending on the server version
2014-11-19 10:21:42 -08:00

65 lines
1.3 KiB
PHP

--TEST--
MongoDB\Manager::executeWriteBatch() with duplicate key errors (unordered)
--SKIPIF--
<?php require "tests/utils/basic-skipif.inc" ?>
--FILE--
<?php
require_once "tests/utils/basic.inc";
$manager = new MongoDB\Manager(MONGODB_URI);
$batch = new MongoDB\WriteBatch(false);
$batch->insert(array('_id' => 1));
$batch->insert(array('_id' => 1));
$batch->insert(array('_id' => 2));
$batch->insert(array('_id' => 2));
try {
$result = $manager->executeWriteBatch(NS, $batch);
echo "FAILED\n";
} catch (MongoDB\WriteException $e) {
printf("WriteException.message: %s\n", $e->getMessage());
printf("WriteException.code: %d\n", $e->getCode());
echo "\n===> WriteResult\n";
printWriteResult($e->getWriteResult());
}
echo "\n===> Collection\n";
$cursor = $manager->executeQuery(NS, new MongoDB\Query(array()));
var_dump(iterator_to_array($cursor));
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
WriteException.message: %s
WriteException.code: 0
===> WriteResult
server: localhost:27017
numInserted: 2
numMatched: 0
numModified: 0
numUpserted: 0
numRemoved: 0
writeError[1].message: %s
writeError[1].code: 11000
writeError[3].message: %s
writeError[3].code: 11000
===> Collection
array(2) {
[0]=>
array(1) {
["_id"]=>
int(1)
}
[1]=>
array(1) {
["_id"]=>
int(2)
}
}
===DONE===