Skip to content

Commit 9eb4a80

Browse files
jmikoladerickr
authored andcommitted
PHPC-459: Update Javascript::jsonSerialize() tests for CDRIVER-1335
The expected output of bson-javascript-jsonserialize-004.phpt is logically incorrect because of an outstanding bug where Javascript objects are always serialized to BSON code types, irrespective of their scope property. That issue will be fixed by PHPC-838.
1 parent 962e5e8 commit 9eb4a80

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

tests/bson/bson-javascript-jsonserialize-003.phpt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ require_once __DIR__ . '/../utils/tools.php';
88
$doc = ['foo' => new MongoDB\BSON\Javascript('function foo(bar) { return bar; }')];
99
$json = json_encode($doc);
1010

11-
/* Note: libbson currently does properly handle Javascript types. Conversion of
12-
* BSON to JSON yields a single code string value instead of a document with
13-
* "$code" and "$scope" fields. Likewise, "$code" and "$scope" fields are not
14-
* parsed when converting JSON to BSON. See CDRIVER-1335 for more info. */
1511
echo toJSON(fromPHP($doc)), "\n";
1612
echo $json, "\n";
1713
var_dump(toPHP(fromJSON($json)));
@@ -20,7 +16,7 @@ var_dump(toPHP(fromJSON($json)));
2016
===DONE===
2117
<?php exit(0); ?>
2218
--EXPECTF--
23-
{ "foo" : "function foo(bar) { return bar; }" }
19+
{ "foo" : { "$code" : "function foo(bar) { return bar; }" } }
2420
{"foo":{"$code":"function foo(bar) { return bar; }"}}
2521
object(stdClass)#%d (%d) {
2622
["foo"]=>

tests/bson/bson-javascript-jsonserialize-004.phpt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ require_once __DIR__ . '/../utils/tools.php';
88
$doc = ['foo' => new MongoDB\BSON\Javascript('function foo(bar) { return bar; }', ['foo' => 42])];
99
$json = json_encode($doc);
1010

11-
/* Note: libbson currently does properly handle Javascript types. Conversion of
12-
* BSON to JSON yields a single code string value instead of a document with
13-
* "$code" and "$scope" fields. Likewise, "$code" and "$scope" fields are not
14-
* parsed when converting JSON to BSON. See CDRIVER-1335 for more info. */
1511
echo toJSON(fromPHP($doc)), "\n";
1612
echo $json, "\n";
1713
var_dump(toPHP(fromJSON($json)));
@@ -20,7 +16,7 @@ var_dump(toPHP(fromJSON($json)));
2016
===DONE===
2117
<?php exit(0); ?>
2218
--EXPECTF--
23-
{ "foo" : "function foo(bar) { return bar; }" }
19+
{ "foo" : { "$code" : "function foo(bar) { return bar; }" } }
2420
{"foo":{"$code":"function foo(bar) { return bar; }","$scope":{"foo":42}}}
2521
object(stdClass)#%d (%d) {
2622
["foo"]=>

0 commit comments

Comments
 (0)