Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/convert-bson-corpus-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test originally tested the wrong type (string). Now that it correctly uses code w/o scope, we need to add an expected failure just as we had for the code w/ scope variant below (for which the test always used the correct type).

'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)',
Expand Down
2 changes: 1 addition & 1 deletion tests/bson-corpus/code-decodeError-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion tests/bson-corpus/code-decodeError-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion tests/bson-corpus/code-decodeError-003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion tests/bson-corpus/code-decodeError-004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion tests/bson-corpus/code-decodeError-005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion tests/bson-corpus/code-decodeError-006.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion tests/bson-corpus/code-decodeError-007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
10 changes: 5 additions & 5 deletions tests/bson-corpus/code-valid-004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -25,7 +25,7 @@ echo bin2hex(fromJSON($canonicalExtJson)), "\n";
===DONE===
<?php exit(0); ?>
--EXPECT--
190000000261000d000000c3a9c3a9c3a9c3a9c3a9c3a90000
{"a":"\u00e9\u00e9\u00e9\u00e9\u00e9\u00e9"}
190000000261000d000000c3a9c3a9c3a9c3a9c3a9c3a90000
190000000d61000d000000c3a9c3a9c3a9c3a9c3a9c3a90000
{"a":{"$code":"\u00e9\u00e9\u00e9\u00e9\u00e9\u00e9"}}
190000000d61000d000000c3a9c3a9c3a9c3a9c3a9c3a90000
===DONE===
10 changes: 5 additions & 5 deletions tests/bson-corpus/code-valid-005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -25,7 +25,7 @@ echo bin2hex(fromJSON($canonicalExtJson)), "\n";
===DONE===
<?php exit(0); ?>
--EXPECT--
190000000261000d000000e29886e29886e29886e298860000
{"a":"\u2606\u2606\u2606\u2606"}
190000000261000d000000e29886e29886e29886e298860000
190000000d61000d000000e29886e29886e29886e298860000
{"a":{"$code":"\u2606\u2606\u2606\u2606"}}
190000000d61000d000000e29886e29886e29886e298860000
===DONE===
12 changes: 7 additions & 5 deletions tests/bson-corpus/code-valid-006.phpt
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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";
Expand All @@ -25,7 +27,7 @@ echo bin2hex(fromJSON($canonicalExtJson)), "\n";
===DONE===
<?php exit(0); ?>
--EXPECT--
190000000261000d0000006162006261620062616261620000
{"a":"ab\u0000bab\u0000babab"}
190000000261000d0000006162006261620062616261620000
190000000d61000d0000006162006261620062616261620000
{"a":{"$code":"ab\u0000bab\u0000babab"}}
190000000d61000d0000006162006261620062616261620000
===DONE===
2 changes: 1 addition & 1 deletion tests/bson-corpus/symbol-decodeError-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion tests/bson-corpus/symbol-decodeError-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion tests/bson-corpus/symbol-decodeError-003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion tests/bson-corpus/symbol-decodeError-004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion tests/bson-corpus/symbol-decodeError-005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion tests/bson-corpus/symbol-decodeError-006.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion tests/bson-corpus/symbol-decodeError-007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down