1
0
mirror of https://github.com/php/php-src.git synced 2026-04-24 16:38:25 +02:00

Add test for fixed bug #68992

This commit is contained in:
Jakub Zelenka
2016-08-28 13:00:49 +01:00
parent df05dbb3df
commit 27acbcf4df
+30
View File
@@ -0,0 +1,30 @@
--TEST--
Bug #68992 (json_encode stacks exceptions thrown by JsonSerializable classes)
--SKIPIF--
<?php
if (!extension_loaded('json')) die('skip');
?>
--FILE--
<?php
class MyClass implements JsonSerializable {
public function jsonSerialize() {
throw new Exception('Not implemented!');
}
}
$classes = [];
for($i = 0; $i < 5; $i++) {
$classes[] = new MyClass();
}
try {
json_encode($classes);
} catch(Exception $e) {
do {
printf("%s (%d) [%s]\n", $e->getMessage(), $e->getCode(), get_class($e));
} while ($e = $e->getPrevious());
}
?>
--EXPECT--
Failed calling MyClass::jsonSerialize() (0) [Exception]
Not implemented! (0) [Exception]