diff --git a/scripts/convert-bson-corpus-tests.php b/scripts/convert-bson-corpus-tests.php index 56a5784d8..d163c8e18 100644 --- a/scripts/convert-bson-corpus-tests.php +++ b/scripts/convert-bson-corpus-tests.php @@ -6,6 +6,7 @@ 'Int64 type: -1' => 'PHP encodes integers as 32-bit if range allows', 'Int64 type: 0' => 'PHP encodes integers as 32-bit if range allows', 'Int64 type: 1' => 'PHP encodes integers as 32-bit if range allows', + 'Javascript Code: Embedded nulls' => 'Embedded null in code string is not supported in libbson (CDRIVER-1879)', 'Javascript Code with Scope: Unicode and embedded null in code string, empty scope' => 'Embedded null in code string is not supported in libbson (CDRIVER-1879)', 'Multiple types within the same document: All BSON types' => 'PHP encodes integers as 32-bit if range allows', 'Top-level document validity: Bad $date (number, not string or hash)' => 'Legacy extended JSON $date syntax uses numbers (CDRIVER-2223)', diff --git a/tests/bson-corpus/code-decodeError-001.phpt b/tests/bson-corpus/code-decodeError-001.phpt index d04d2d9d9..39b9d206b 100644 --- a/tests/bson-corpus/code-decodeError-001.phpt +++ b/tests/bson-corpus/code-decodeError-001.phpt @@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/basic.inc'; -$bson = hex2bin('0C0000000261000000000000'); +$bson = hex2bin('0C0000000D61000000000000'); throws(function() use ($bson) { var_dump(toPHP($bson)); diff --git a/tests/bson-corpus/code-decodeError-002.phpt b/tests/bson-corpus/code-decodeError-002.phpt index 863efa740..11aac3cd5 100644 --- a/tests/bson-corpus/code-decodeError-002.phpt +++ b/tests/bson-corpus/code-decodeError-002.phpt @@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/basic.inc'; -$bson = hex2bin('0C000000026100FFFFFFFF00'); +$bson = hex2bin('0C0000000D6100FFFFFFFF00'); throws(function() use ($bson) { var_dump(toPHP($bson)); diff --git a/tests/bson-corpus/code-decodeError-003.phpt b/tests/bson-corpus/code-decodeError-003.phpt index 2677438e6..9d3749029 100644 --- a/tests/bson-corpus/code-decodeError-003.phpt +++ b/tests/bson-corpus/code-decodeError-003.phpt @@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/basic.inc'; -$bson = hex2bin('10000000026100050000006200620000'); +$bson = hex2bin('100000000D6100050000006200620000'); throws(function() use ($bson) { var_dump(toPHP($bson)); diff --git a/tests/bson-corpus/code-decodeError-004.phpt b/tests/bson-corpus/code-decodeError-004.phpt index f31f409ca..8beaf0aa4 100644 --- a/tests/bson-corpus/code-decodeError-004.phpt +++ b/tests/bson-corpus/code-decodeError-004.phpt @@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/basic.inc'; -$bson = hex2bin('120000000200FFFFFF00666F6F6261720000'); +$bson = hex2bin('120000000D00FFFFFF00666F6F6261720000'); throws(function() use ($bson) { var_dump(toPHP($bson)); diff --git a/tests/bson-corpus/code-decodeError-005.phpt b/tests/bson-corpus/code-decodeError-005.phpt index a871d0286..1407b247d 100644 --- a/tests/bson-corpus/code-decodeError-005.phpt +++ b/tests/bson-corpus/code-decodeError-005.phpt @@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/basic.inc'; -$bson = hex2bin('1000000002610004000000616263FF00'); +$bson = hex2bin('100000000D610004000000616263FF00'); throws(function() use ($bson) { var_dump(toPHP($bson)); diff --git a/tests/bson-corpus/code-decodeError-006.phpt b/tests/bson-corpus/code-decodeError-006.phpt index d08045608..be1bbaa96 100644 --- a/tests/bson-corpus/code-decodeError-006.phpt +++ b/tests/bson-corpus/code-decodeError-006.phpt @@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/basic.inc'; -$bson = hex2bin('0E00000002610001000000000000'); +$bson = hex2bin('0E0000000D610001000000000000'); throws(function() use ($bson) { var_dump(toPHP($bson)); diff --git a/tests/bson-corpus/code-decodeError-007.phpt b/tests/bson-corpus/code-decodeError-007.phpt index 1ffc4b766..ff0abe06f 100644 --- a/tests/bson-corpus/code-decodeError-007.phpt +++ b/tests/bson-corpus/code-decodeError-007.phpt @@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/basic.inc'; -$bson = hex2bin('0E00000002610002000000E90000'); +$bson = hex2bin('0E0000000D610002000000E90000'); throws(function() use ($bson) { var_dump(toPHP($bson)); diff --git a/tests/bson-corpus/code-valid-004.phpt b/tests/bson-corpus/code-valid-004.phpt index 5c6586224..ee69d392c 100644 --- a/tests/bson-corpus/code-valid-004.phpt +++ b/tests/bson-corpus/code-valid-004.phpt @@ -9,8 +9,8 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/basic.inc'; -$canonicalBson = hex2bin('190000000261000D000000C3A9C3A9C3A9C3A9C3A9C3A90000'); -$canonicalExtJson = '{"a" : "\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9"}'; +$canonicalBson = hex2bin('190000000D61000D000000C3A9C3A9C3A9C3A9C3A9C3A90000'); +$canonicalExtJson = '{"a" : {"$code" : "\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9"}}'; // Canonical BSON -> Native -> Canonical BSON echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n"; @@ -25,7 +25,7 @@ echo bin2hex(fromJSON($canonicalExtJson)), "\n"; ===DONE=== --EXPECT-- -190000000261000d000000c3a9c3a9c3a9c3a9c3a9c3a90000 -{"a":"\u00e9\u00e9\u00e9\u00e9\u00e9\u00e9"} -190000000261000d000000c3a9c3a9c3a9c3a9c3a9c3a90000 +190000000d61000d000000c3a9c3a9c3a9c3a9c3a9c3a90000 +{"a":{"$code":"\u00e9\u00e9\u00e9\u00e9\u00e9\u00e9"}} +190000000d61000d000000c3a9c3a9c3a9c3a9c3a9c3a90000 ===DONE=== \ No newline at end of file diff --git a/tests/bson-corpus/code-valid-005.phpt b/tests/bson-corpus/code-valid-005.phpt index 9371a3874..c1bd193b3 100644 --- a/tests/bson-corpus/code-valid-005.phpt +++ b/tests/bson-corpus/code-valid-005.phpt @@ -9,8 +9,8 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/basic.inc'; -$canonicalBson = hex2bin('190000000261000D000000E29886E29886E29886E298860000'); -$canonicalExtJson = '{"a" : "\\u2606\\u2606\\u2606\\u2606"}'; +$canonicalBson = hex2bin('190000000D61000D000000E29886E29886E29886E298860000'); +$canonicalExtJson = '{"a" : {"$code" : "\\u2606\\u2606\\u2606\\u2606"}}'; // Canonical BSON -> Native -> Canonical BSON echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n"; @@ -25,7 +25,7 @@ echo bin2hex(fromJSON($canonicalExtJson)), "\n"; ===DONE=== --EXPECT-- -190000000261000d000000e29886e29886e29886e298860000 -{"a":"\u2606\u2606\u2606\u2606"} -190000000261000d000000e29886e29886e29886e298860000 +190000000d61000d000000e29886e29886e29886e298860000 +{"a":{"$code":"\u2606\u2606\u2606\u2606"}} +190000000d61000d000000e29886e29886e29886e298860000 ===DONE=== \ No newline at end of file diff --git a/tests/bson-corpus/code-valid-006.phpt b/tests/bson-corpus/code-valid-006.phpt index 6aa1d470e..483fbc4ae 100644 --- a/tests/bson-corpus/code-valid-006.phpt +++ b/tests/bson-corpus/code-valid-006.phpt @@ -1,5 +1,7 @@ --TEST-- Javascript Code: Embedded nulls +--XFAIL-- +Embedded null in code string is not supported in libbson (CDRIVER-1879) --DESCRIPTION-- Generated by scripts/convert-bson-corpus-tests.php @@ -9,8 +11,8 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/basic.inc'; -$canonicalBson = hex2bin('190000000261000D0000006162006261620062616261620000'); -$canonicalExtJson = '{"a" : "ab\\u0000bab\\u0000babab"}'; +$canonicalBson = hex2bin('190000000D61000D0000006162006261620062616261620000'); +$canonicalExtJson = '{"a" : {"$code" : "ab\\u0000bab\\u0000babab"}}'; // Canonical BSON -> Native -> Canonical BSON echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n"; @@ -25,7 +27,7 @@ echo bin2hex(fromJSON($canonicalExtJson)), "\n"; ===DONE=== --EXPECT-- -190000000261000d0000006162006261620062616261620000 -{"a":"ab\u0000bab\u0000babab"} -190000000261000d0000006162006261620062616261620000 +190000000d61000d0000006162006261620062616261620000 +{"a":{"$code":"ab\u0000bab\u0000babab"}} +190000000d61000d0000006162006261620062616261620000 ===DONE=== \ No newline at end of file diff --git a/tests/bson-corpus/symbol-decodeError-001.phpt b/tests/bson-corpus/symbol-decodeError-001.phpt index 2bf260fa1..92cbcb492 100644 --- a/tests/bson-corpus/symbol-decodeError-001.phpt +++ b/tests/bson-corpus/symbol-decodeError-001.phpt @@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/basic.inc'; -$bson = hex2bin('0C0000000261000000000000'); +$bson = hex2bin('0C0000000E61000000000000'); throws(function() use ($bson) { var_dump(toPHP($bson)); diff --git a/tests/bson-corpus/symbol-decodeError-002.phpt b/tests/bson-corpus/symbol-decodeError-002.phpt index 38eb86d00..dd46d578e 100644 --- a/tests/bson-corpus/symbol-decodeError-002.phpt +++ b/tests/bson-corpus/symbol-decodeError-002.phpt @@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/basic.inc'; -$bson = hex2bin('0C000000026100FFFFFFFF00'); +$bson = hex2bin('0C0000000E6100FFFFFFFF00'); throws(function() use ($bson) { var_dump(toPHP($bson)); diff --git a/tests/bson-corpus/symbol-decodeError-003.phpt b/tests/bson-corpus/symbol-decodeError-003.phpt index a8af7fabc..75c723b52 100644 --- a/tests/bson-corpus/symbol-decodeError-003.phpt +++ b/tests/bson-corpus/symbol-decodeError-003.phpt @@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/basic.inc'; -$bson = hex2bin('10000000026100050000006200620000'); +$bson = hex2bin('100000000E6100050000006200620000'); throws(function() use ($bson) { var_dump(toPHP($bson)); diff --git a/tests/bson-corpus/symbol-decodeError-004.phpt b/tests/bson-corpus/symbol-decodeError-004.phpt index 8f9e6d48e..c6cb0cd2e 100644 --- a/tests/bson-corpus/symbol-decodeError-004.phpt +++ b/tests/bson-corpus/symbol-decodeError-004.phpt @@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/basic.inc'; -$bson = hex2bin('120000000200FFFFFF00666F6F6261720000'); +$bson = hex2bin('120000000E00FFFFFF00666F6F6261720000'); throws(function() use ($bson) { var_dump(toPHP($bson)); diff --git a/tests/bson-corpus/symbol-decodeError-005.phpt b/tests/bson-corpus/symbol-decodeError-005.phpt index b5224bfcc..1df0ab732 100644 --- a/tests/bson-corpus/symbol-decodeError-005.phpt +++ b/tests/bson-corpus/symbol-decodeError-005.phpt @@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/basic.inc'; -$bson = hex2bin('1000000002610004000000616263FF00'); +$bson = hex2bin('100000000E610004000000616263FF00'); throws(function() use ($bson) { var_dump(toPHP($bson)); diff --git a/tests/bson-corpus/symbol-decodeError-006.phpt b/tests/bson-corpus/symbol-decodeError-006.phpt index 400f2fb7e..0ae6e62ae 100644 --- a/tests/bson-corpus/symbol-decodeError-006.phpt +++ b/tests/bson-corpus/symbol-decodeError-006.phpt @@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/basic.inc'; -$bson = hex2bin('0E00000002610001000000000000'); +$bson = hex2bin('0E0000000E610001000000000000'); throws(function() use ($bson) { var_dump(toPHP($bson)); diff --git a/tests/bson-corpus/symbol-decodeError-007.phpt b/tests/bson-corpus/symbol-decodeError-007.phpt index 4c6a087ef..ceb14123c 100644 --- a/tests/bson-corpus/symbol-decodeError-007.phpt +++ b/tests/bson-corpus/symbol-decodeError-007.phpt @@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/basic.inc'; -$bson = hex2bin('0E00000002610002000000E90000'); +$bson = hex2bin('0E0000000E610002000000E90000'); throws(function() use ($bson) { var_dump(toPHP($bson));