Page MenuHomePhabricator (Chris)

bson-document-toPHP_error-002.phpt
No OneTemporary

Authored By
Unknown
Size
675 B
Referenced Files
None
Subscribers
None

bson-document-toPHP_error-002.phpt

--TEST--
MongoDB\BSON\Document::toPHP(): exception thrown in Unserializable::bsonUnserialize() propagates (root document)
--FILE--
<?php
require_once __DIR__ . '/../utils/basic.inc';
class ThrowingClass implements MongoDB\BSON\Unserializable
{
public function bsonUnserialize(array $data): void
{
throw new RuntimeException('bsonUnserialize threw');
}
}
$bson = MongoDB\BSON\Document::fromPHP(['foo' => 'bar', 'baz' => 42]);
echo throws(function() use ($bson) {
$bson->toPHP(['root' => ThrowingClass::class]);
}, RuntimeException::class), "\n";
?>
===DONE===
<?php exit(0); ?>
--EXPECT--
OK: Got RuntimeException
bsonUnserialize threw
===DONE===

File Metadata

Mime Type
application/javascript
Expires
Sun, Nov 15, 12:27 PM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
152327
Default Alt Text
bson-document-toPHP_error-002.phpt (675 B)

Event Timeline