|
| 1 | +--TEST-- |
| 2 | +Bug #76502: Chain of mixed exceptions and errors does not serialize properly |
| 3 | +--FILE-- |
| 4 | +<?php |
| 5 | + |
| 6 | +$examples = [ |
| 7 | + "Exception(Exception())" => new Exception("outer", 0, new Exception("inner")), |
| 8 | + "Error(Error())" => new Error("outer", 0, new Error("inner")), |
| 9 | + "Error(Exception())" => new Error("outer", 0, new Exception("inner")), |
| 10 | + "Exception(Error())" => new Exception("outer", 0, new Error("inner")) |
| 11 | +]; |
| 12 | + |
| 13 | +foreach ($examples as $name => $example) { |
| 14 | + $processed = unserialize(serialize($example)); |
| 15 | + $processedPrev = $processed->getPrevious(); |
| 16 | + echo "---- $name ----\n"; |
| 17 | + echo "before: ", get_class($example), ".previous == ", |
| 18 | + get_class($example->getPrevious()), "\n"; |
| 19 | + echo "after : ", get_class($processed), ".previous == ", |
| 20 | + $processedPrev ? get_class($processedPrev) : "null", "\n"; |
| 21 | +} |
| 22 | + |
| 23 | +?> |
| 24 | +--EXPECT-- |
| 25 | +---- Exception(Exception()) ---- |
| 26 | +before: Exception.previous == Exception |
| 27 | +after : Exception.previous == Exception |
| 28 | +---- Error(Error()) ---- |
| 29 | +before: Error.previous == Error |
| 30 | +after : Error.previous == Error |
| 31 | +---- Error(Exception()) ---- |
| 32 | +before: Error.previous == Exception |
| 33 | +after : Error.previous == Exception |
| 34 | +---- Exception(Error()) ---- |
| 35 | +before: Exception.previous == Error |
| 36 | +after : Exception.previous == Error |
0 commit comments