|
| 1 | +--TEST-- |
| 2 | +MongoDB\Driver\BulkWriteCommand::deleteOne() with BSON encoding error (null bytes in keys) |
| 3 | +--FILE-- |
| 4 | +<?php |
| 5 | + |
| 6 | +require_once __DIR__ . '/../utils/basic.inc'; |
| 7 | + |
| 8 | +$bulk = new MongoDB\Driver\BulkWriteCommand; |
| 9 | + |
| 10 | +echo throws(function() use ($bulk) { |
| 11 | + $bulk->deleteOne(NS, ["\0" => 1]); |
| 12 | +}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n\n"; |
| 13 | + |
| 14 | +echo throws(function() use ($bulk) { |
| 15 | + $bulk->deleteOne(NS, ["x\0" => 1]); |
| 16 | +}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n\n"; |
| 17 | + |
| 18 | +echo throws(function() use ($bulk) { |
| 19 | + $bulk->deleteOne(NS, ["\0\0\0" => 1]); |
| 20 | +}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n\n"; |
| 21 | + |
| 22 | +echo throws(function() use ($bulk) { |
| 23 | + $bulk->deleteOne(NS, ['x' => 1], ['collation' => ["\0" => 1]]); |
| 24 | +}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n\n"; |
| 25 | + |
| 26 | +echo throws(function() use ($bulk) { |
| 27 | + $bulk->deleteOne(NS, ['x' => 1], ['collation' => ["x\0" => 1]]); |
| 28 | +}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n\n"; |
| 29 | + |
| 30 | +echo throws(function() use ($bulk) { |
| 31 | + $bulk->deleteOne(NS, ['x' => 1], ['collation' => ["\0\0\0" => 1]]); |
| 32 | +}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; |
| 33 | + |
| 34 | +?> |
| 35 | +===DONE=== |
| 36 | +<?php exit(0); ?> |
| 37 | +--EXPECT-- |
| 38 | +OK: Got MongoDB\Driver\Exception\UnexpectedValueException |
| 39 | +BSON keys cannot contain null bytes. Unexpected null byte after "". |
| 40 | + |
| 41 | +OK: Got MongoDB\Driver\Exception\UnexpectedValueException |
| 42 | +BSON keys cannot contain null bytes. Unexpected null byte after "x". |
| 43 | + |
| 44 | +OK: Got MongoDB\Driver\Exception\UnexpectedValueException |
| 45 | +BSON keys cannot contain null bytes. Unexpected null byte after "". |
| 46 | + |
| 47 | +OK: Got MongoDB\Driver\Exception\UnexpectedValueException |
| 48 | +BSON keys cannot contain null bytes. Unexpected null byte after "". |
| 49 | + |
| 50 | +OK: Got MongoDB\Driver\Exception\UnexpectedValueException |
| 51 | +BSON keys cannot contain null bytes. Unexpected null byte after "x". |
| 52 | + |
| 53 | +OK: Got MongoDB\Driver\Exception\UnexpectedValueException |
| 54 | +BSON keys cannot contain null bytes. Unexpected null byte after "". |
| 55 | +===DONE=== |
0 commit comments