mirror of
https://github.com/macintoshplus/mongo-php-driver.git
synced 2026-04-23 16:38:08 +02:00
deead9687e
* Introduce MongoDB\Driver\ServerApi * Accept serverApi driver option * Introduce create_test_manager factory to create manager A centralised entry point is required to inject the API_VERSION env variable later. * Add build variant to test with requireApiVersion=true * Fix wrong configuration for auth variable This changed when migrating from our own scripts to drivers-evergreen-tools and was not updated properly, causing all tests to run with auth disabled. * Declare ZEND_PARSE_PARAMETERS_NONE macro This macro is missing on PHP < 7.3 * Remove duplicated API param storage * Add missing semicolons * Add ZEND_PARSE_PARAMETERS_NON_EX macro * Extract error handling functionality to separate macros * Throw if internal mongoc_server_api_t is already initialised * Use imported namespaces in tools file * Fix type info for reflection * Use American English spelling * Only use typed serialize signature on PHP 8+ * Update PHONGO_PARSE_PARAMETERS_NONE macro for PHP < 7.3 * Remove usage of ZEND_STRL within zend_hash_str_add This causes compile failures on PHP < 7.3 that I have yet to understand. * Fix errors in new PHONGO_PARSE_PARAMETERS macros
39 lines
1.4 KiB
PHP
39 lines
1.4 KiB
PHP
--TEST--
|
|
MongoDB\BSON\toJSON(): BSON decoding exceptions for bson_as_json() failure
|
|
--FILE--
|
|
<?php
|
|
|
|
require_once __DIR__ . '/../utils/basic.inc';
|
|
|
|
$tests = [
|
|
// Invalid UTF-8 characters (i.e. 0xFE, 0xFF) in field name
|
|
pack('VCCCxVa*xx', 17, 2, 254, 255, 3, 'bar'),
|
|
/* Note: we don't use a three-character string in the underflow case, as
|
|
* the 4-byte string length and payload (i.e. three characters + null byte)
|
|
* coincidentally satisfy the expected size for an 8-byte double. We also
|
|
* don't use a four-character string, since its null byte would be
|
|
* interpreted as the document terminator. The actual document terminator
|
|
* would then remain in the buffer and trigger a "did not exhaust" error.
|
|
*/
|
|
pack('VCa*xVa*xx', 17, 1, 'foo', 3, 'ab'), // Invalid field type (underflow)
|
|
pack('VCa*xVa*xx', 20, 1, 'foo', 6, 'abcde'), // Invalid field type (overflow)
|
|
];
|
|
|
|
foreach ($tests as $bson) {
|
|
echo throws(function() use ($bson) {
|
|
toJSON($bson);
|
|
}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n";
|
|
}
|
|
|
|
?>
|
|
===DONE===
|
|
<?php exit(0); ?>
|
|
--EXPECT--
|
|
OK: Got MongoDB\Driver\Exception\UnexpectedValueException
|
|
Could not convert BSON document to a JSON string
|
|
OK: Got MongoDB\Driver\Exception\UnexpectedValueException
|
|
Could not convert BSON document to a JSON string
|
|
OK: Got MongoDB\Driver\Exception\UnexpectedValueException
|
|
Could not convert BSON document to a JSON string
|
|
===DONE===
|