Skip to content

Commit

Permalink
Add test for fixed bug #68992
Browse files Browse the repository at this point in the history
  • Loading branch information
bukka committed Aug 29, 2016
1 parent df05dbb commit 27acbcf
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions ext/json/tests/bug68992.phpt
Original file line number Diff line number Diff line change
@@ -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]

0 comments on commit 27acbcf

Please sign in to comment.