Skip to content

Commit 8882fe3

Browse files
committed
Update tests for new BSON validation logic
1 parent 3635cc1 commit 8882fe3

File tree

3 files changed

+3
-24
lines changed

3 files changed

+3
-24
lines changed

tests/bulk/bulkwrite-insert_error-001.phpt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,12 @@ $bulk = new MongoDB\Driver\BulkWrite;
99

1010
echo throws(function() use ($bulk) {
1111
$bulk->insert(['' => 1]);
12-
}, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n\n";
13-
14-
echo throws(function() use ($bulk) {
15-
$bulk->insert(["\xc3\x28" => 1]);
1612
}, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n";
1713

1814
?>
1915
===DONE===
2016
<?php exit(0); ?>
2117
--EXPECT--
2218
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
23-
invalid document for insert: empty key
24-
25-
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
26-
invalid document for insert: corrupt BSON
19+
invalid document for insert: Element key cannot be an empty string
2720
===DONE===

tests/bulk/bulkwrite-update_error-001.phpt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,12 @@ $bulk = new MongoDB\Driver\BulkWrite;
99

1010
echo throws(function() use ($bulk) {
1111
$bulk->update(['x' => 1], ['' => 1]);
12-
}, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n\n";
13-
14-
echo throws(function() use ($bulk) {
15-
$bulk->update(['x' => 1], ["\xc3\x28" => 1]);
1612
}, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n";
1713

1814
?>
1915
===DONE===
2016
<?php exit(0); ?>
2117
--EXPECT--
2218
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
23-
invalid argument for replace: empty key
24-
25-
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
26-
invalid argument for replace: corrupt BSON
19+
invalid argument for replace: Element key cannot be an empty string
2720
===DONE===

tests/bulk/bulkwrite-update_error-002.phpt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ echo throws(function() use ($bulk) {
1111
$bulk->update(['x' => 1], ['$set' => ['x' => ['' => 1]]]);
1212
}, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n\n";
1313

14-
echo throws(function() use ($bulk) {
15-
$bulk->update(['x' => 1], ['$set' => ['x' => ["\xc3\x28" => 1]]]);
16-
}, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n\n";
17-
1814
/* This newObj argument mixes an update and replacement document, but
1915
* php_phongo_bulkwrite_update_has_operators() will categorize it as an update
2016
* due to the presence of an atomic operator. As such, _mongoc_validate_update()
@@ -28,10 +24,7 @@ echo throws(function() use ($bulk) {
2824
<?php exit(0); ?>
2925
--EXPECT--
3026
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
31-
invalid argument for update: empty key
32-
33-
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
34-
invalid argument for update: corrupt BSON
27+
invalid argument for update: Element key cannot be an empty string
3528

3629
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
3730
Invalid key 'z': update only works with $ operators and pipelines

0 commit comments

Comments
 (0)