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
2 changes: 1 addition & 1 deletion tests/bson-corpus/array-valid-003.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Array: Single Element Array with index set incorrectly
Array: Single Element Array with index set incorrectly to empty string
--DESCRIPTION--
Generated by scripts/convert-bson-corpus-tests.php

Expand Down
2 changes: 1 addition & 1 deletion tests/bson-corpus/array-valid-004.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Array: Single Element Array with index set incorrectly
Array: Single Element Array with index set incorrectly to ab
--DESCRIPTION--
Generated by scripts/convert-bson-corpus-tests.php

Expand Down
40 changes: 40 additions & 0 deletions tests/bson-corpus/array-valid-005.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--TEST--
Array: Multi Element Array with duplicate indexes
--DESCRIPTION--
Generated by scripts/convert-bson-corpus-tests.php

DO NOT EDIT THIS FILE
--FILE--
<?php

require_once __DIR__ . '/../utils/tools.php';

$canonicalBson = hex2bin('1b000000046100130000001030000a000000103100140000000000');
$degenerateBson = hex2bin('1b000000046100130000001030000a000000103000140000000000');
$canonicalExtJson = '{"a" : [{"$numberInt": "10"}, {"$numberInt": "20"}]}';

// Canonical BSON -> Native -> Canonical BSON
echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n";

// Canonical BSON -> Canonical extJSON
echo json_canonicalize(toCanonicalExtendedJSON($canonicalBson)), "\n";

// Canonical extJSON -> Canonical BSON
echo bin2hex(fromJSON($canonicalExtJson)), "\n";

// Degenerate BSON -> Native -> Canonical BSON
echo bin2hex(fromPHP(toPHP($degenerateBson))), "\n";

// Degenerate BSON -> Canonical extJSON
echo json_canonicalize(toCanonicalExtendedJSON($degenerateBson)), "\n";

?>
===DONE===
<?php exit(0); ?>
--EXPECT--
1b000000046100130000001030000a000000103100140000000000
{"a":[{"$numberInt":"10"},{"$numberInt":"20"}]}
1b000000046100130000001030000a000000103100140000000000
1b000000046100130000001030000a000000103100140000000000
{"a":[{"$numberInt":"10"},{"$numberInt":"20"}]}
===DONE===
40 changes: 40 additions & 0 deletions tests/bson-corpus/datetime-valid-005.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--TEST--
DateTime: leading zero ms
--DESCRIPTION--
Generated by scripts/convert-bson-corpus-tests.php

DO NOT EDIT THIS FILE
--FILE--
<?php

require_once __DIR__ . '/../utils/tools.php';

$canonicalBson = hex2bin('10000000096100D1D6D6CC3B01000000');
$canonicalExtJson = '{"a" : {"$date" : {"$numberLong" : "1356351330001"}}}';
$relaxedExtJson = '{"a" : {"$date" : "2012-12-24T12:15:30.001Z"}}';

// Canonical BSON -> Native -> Canonical BSON
echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n";

// Canonical BSON -> Canonical extJSON
echo json_canonicalize(toCanonicalExtendedJSON($canonicalBson)), "\n";

// Canonical BSON -> Relaxed extJSON
echo json_canonicalize(toRelaxedExtendedJSON($canonicalBson)), "\n";

// Canonical extJSON -> Canonical BSON
echo bin2hex(fromJSON($canonicalExtJson)), "\n";

// Relaxed extJSON -> BSON -> Relaxed extJSON
echo json_canonicalize(toRelaxedExtendedJSON(fromJSON($relaxedExtJson))), "\n";

?>
===DONE===
<?php exit(0); ?>
--EXPECT--
10000000096100d1d6d6cc3b01000000
{"a":{"$date":{"$numberLong":"1356351330001"}}}
{"a":{"$date":"2012-12-24T12:15:30.001Z"}}
10000000096100d1d6d6cc3b01000000
{"a":{"$date":"2012-12-24T12:15:30.001Z"}}
===DONE===