Skip to content

Commit e2ba410

Browse files
authored
PHPC-1918: Update Javascript and Symbol BSON corpus tests (#1256)
Synced with mongodb/specifications@c4cc034
1 parent 45dd0df commit e2ba410

18 files changed

+32
-29
lines changed

scripts/convert-bson-corpus-tests.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
'Int64 type: -1' => 'PHP encodes integers as 32-bit if range allows',
77
'Int64 type: 0' => 'PHP encodes integers as 32-bit if range allows',
88
'Int64 type: 1' => 'PHP encodes integers as 32-bit if range allows',
9+
'Javascript Code: Embedded nulls' => 'Embedded null in code string is not supported in libbson (CDRIVER-1879)',
910
'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)',
1011
'Multiple types within the same document: All BSON types' => 'PHP encodes integers as 32-bit if range allows',
1112
'Top-level document validity: Bad $date (number, not string or hash)' => 'Legacy extended JSON $date syntax uses numbers (CDRIVER-2223)',

tests/bson-corpus/code-decodeError-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE
99

1010
require_once __DIR__ . '/../utils/basic.inc';
1111

12-
$bson = hex2bin('0C0000000261000000000000');
12+
$bson = hex2bin('0C0000000D61000000000000');
1313

1414
throws(function() use ($bson) {
1515
var_dump(toPHP($bson));

tests/bson-corpus/code-decodeError-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE
99

1010
require_once __DIR__ . '/../utils/basic.inc';
1111

12-
$bson = hex2bin('0C000000026100FFFFFFFF00');
12+
$bson = hex2bin('0C0000000D6100FFFFFFFF00');
1313

1414
throws(function() use ($bson) {
1515
var_dump(toPHP($bson));

tests/bson-corpus/code-decodeError-003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE
99

1010
require_once __DIR__ . '/../utils/basic.inc';
1111

12-
$bson = hex2bin('10000000026100050000006200620000');
12+
$bson = hex2bin('100000000D6100050000006200620000');
1313

1414
throws(function() use ($bson) {
1515
var_dump(toPHP($bson));

tests/bson-corpus/code-decodeError-004.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE
99

1010
require_once __DIR__ . '/../utils/basic.inc';
1111

12-
$bson = hex2bin('120000000200FFFFFF00666F6F6261720000');
12+
$bson = hex2bin('120000000D00FFFFFF00666F6F6261720000');
1313

1414
throws(function() use ($bson) {
1515
var_dump(toPHP($bson));

tests/bson-corpus/code-decodeError-005.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE
99

1010
require_once __DIR__ . '/../utils/basic.inc';
1111

12-
$bson = hex2bin('1000000002610004000000616263FF00');
12+
$bson = hex2bin('100000000D610004000000616263FF00');
1313

1414
throws(function() use ($bson) {
1515
var_dump(toPHP($bson));

tests/bson-corpus/code-decodeError-006.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE
99

1010
require_once __DIR__ . '/../utils/basic.inc';
1111

12-
$bson = hex2bin('0E00000002610001000000000000');
12+
$bson = hex2bin('0E0000000D610001000000000000');
1313

1414
throws(function() use ($bson) {
1515
var_dump(toPHP($bson));

tests/bson-corpus/code-decodeError-007.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ DO NOT EDIT THIS FILE
99

1010
require_once __DIR__ . '/../utils/basic.inc';
1111

12-
$bson = hex2bin('0E00000002610002000000E90000');
12+
$bson = hex2bin('0E0000000D610002000000E90000');
1313

1414
throws(function() use ($bson) {
1515
var_dump(toPHP($bson));

tests/bson-corpus/code-valid-004.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ DO NOT EDIT THIS FILE
99

1010
require_once __DIR__ . '/../utils/basic.inc';
1111

12-
$canonicalBson = hex2bin('190000000261000D000000C3A9C3A9C3A9C3A9C3A9C3A90000');
13-
$canonicalExtJson = '{"a" : "\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9"}';
12+
$canonicalBson = hex2bin('190000000D61000D000000C3A9C3A9C3A9C3A9C3A9C3A90000');
13+
$canonicalExtJson = '{"a" : {"$code" : "\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9"}}';
1414

1515
// Canonical BSON -> Native -> Canonical BSON
1616
echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n";
@@ -25,7 +25,7 @@ echo bin2hex(fromJSON($canonicalExtJson)), "\n";
2525
===DONE===
2626
<?php exit(0); ?>
2727
--EXPECT--
28-
190000000261000d000000c3a9c3a9c3a9c3a9c3a9c3a90000
29-
{"a":"\u00e9\u00e9\u00e9\u00e9\u00e9\u00e9"}
30-
190000000261000d000000c3a9c3a9c3a9c3a9c3a9c3a90000
28+
190000000d61000d000000c3a9c3a9c3a9c3a9c3a9c3a90000
29+
{"a":{"$code":"\u00e9\u00e9\u00e9\u00e9\u00e9\u00e9"}}
30+
190000000d61000d000000c3a9c3a9c3a9c3a9c3a9c3a90000
3131
===DONE===

tests/bson-corpus/code-valid-005.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ DO NOT EDIT THIS FILE
99

1010
require_once __DIR__ . '/../utils/basic.inc';
1111

12-
$canonicalBson = hex2bin('190000000261000D000000E29886E29886E29886E298860000');
13-
$canonicalExtJson = '{"a" : "\\u2606\\u2606\\u2606\\u2606"}';
12+
$canonicalBson = hex2bin('190000000D61000D000000E29886E29886E29886E298860000');
13+
$canonicalExtJson = '{"a" : {"$code" : "\\u2606\\u2606\\u2606\\u2606"}}';
1414

1515
// Canonical BSON -> Native -> Canonical BSON
1616
echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n";
@@ -25,7 +25,7 @@ echo bin2hex(fromJSON($canonicalExtJson)), "\n";
2525
===DONE===
2626
<?php exit(0); ?>
2727
--EXPECT--
28-
190000000261000d000000e29886e29886e29886e298860000
29-
{"a":"\u2606\u2606\u2606\u2606"}
30-
190000000261000d000000e29886e29886e29886e298860000
28+
190000000d61000d000000e29886e29886e29886e298860000
29+
{"a":{"$code":"\u2606\u2606\u2606\u2606"}}
30+
190000000d61000d000000e29886e29886e29886e298860000
3131
===DONE===

0 commit comments

Comments
 (0)