Files
mongo-php-driver/tests/bson/bson-javascript_error-003.phpt
T
Jeremy Mikola b63c10f5f9 PHPC-310: Make BSON types final and disable serialization for now
PHONGO_CE_INIT() is used to both make the classes final and disable serialization. Additionally, we provide __wakeUp() to ensure deserialization is also disabled (per PHPC-190).

Eventually, BSON types will allow serialization (see PHPC-460) and the included error tests may be revised.
2015-10-19 17:58:14 -04:00

29 lines
679 B
PHP

--TEST--
BSON BSON\Javascript cannot be serialized
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
use MongoDB\BSON as BSON;
echo throws(function() {
serialize(new BSON\Javascript('function() {}'));
}, 'Exception'), "\n";
echo throws(function() {
$classname = BSON_NAMESPACE . '\Javascript';
unserialize(sprintf('C:%d:"%s":0:{}', strlen($classname), $classname));
}, 'Exception'), "\n";
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
OK: Got Exception
Serialization of '%SBSON\Javascript' is not allowed
OK: Got Exception
Unserialization of '%SBSON\Javascript' is not allowed
===DONE===