Viewing File: /opt/alt/tests/alt-php83-pecl-mongodb_1.18.1-1.el8/tests/bson-document-toRelaxedJSON-001.phpt
--TEST--
MongoDB\BSON\Document::toRelaxedExtendedJSON(): Encoding JSON
--FILE--
<?php
require_once __DIR__ . '/../utils/basic.inc';
$tests = [
[],
[ 'null' => null ],
[ 'boolean' => true ],
[ 'string' => 'foo' ],
[ 'integer' => 123 ],
[ 'double' => 1.0, ],
[ 'nan' => NAN ],
[ 'pos_inf' => INF ],
[ 'neg_inf' => -INF ],
[ 'array' => [ 'foo', 'bar' ]],
[ 'document' => [ 'foo' => 'bar' ]],
];
foreach ($tests as $value) {
echo MongoDB\BSON\Document::fromPHP($value)->toRelaxedExtendedJSON(), "\n";
}
?>
===DONE===
<?php exit(0); ?>
--EXPECT--
{ }
{ "null" : null }
{ "boolean" : true }
{ "string" : "foo" }
{ "integer" : 123 }
{ "double" : 1.0 }
{ "nan" : { "$numberDouble" : "NaN" } }
{ "pos_inf" : { "$numberDouble" : "Infinity" } }
{ "neg_inf" : { "$numberDouble" : "-Infinity" } }
{ "array" : [ "foo", "bar" ] }
{ "document" : { "foo" : "bar" } }
===DONE===
Back to Directory
File Manager
<