diff --git a/test/compliance/cases/stdlib/exception_previous_chain.phpt b/test/compliance/cases/stdlib/exception_previous_chain.phpt new file mode 100644 index 00000000000..87548914904 --- /dev/null +++ b/test/compliance/cases/stdlib/exception_previous_chain.phpt @@ -0,0 +1,25 @@ +--TEST-- +Stdlib: Exception three-arg ctor + getPrevious() chain (#5104, zend_exceptions.c) +--FILE-- +getPrevious(); +echo 'previous_is_exception=', ($prev instanceof Exception) ? 'true' : 'false', "\n"; +echo 'previous_message=', $prev instanceof Exception ? $prev->getMessage() : 'null', "\n"; +echo 'inner_previous_null=', (null === $inner->getPrevious()) ? 'true' : 'false', "\n"; + +$chain = (string) $outer; +echo 'chain_has_next=', (str_contains($chain, 'Next Exception')) ? 'true' : 'false', "\n"; +echo 'chain_has_inner=', (str_contains($chain, 'inner')) ? 'true' : 'false', "\n"; +echo 'chain_has_outer=', (str_contains($chain, 'outer')) ? 'true' : 'false', "\n"; +--EXPECT-- +previous_is_exception=true +previous_message=inner +inner_previous_null=true +chain_has_next=true +chain_has_inner=true +chain_has_outer=true diff --git a/test/repro/exception_previous_chain.php b/test/repro/exception_previous_chain.php new file mode 100644 index 00000000000..d65096bb4ca --- /dev/null +++ b/test/repro/exception_previous_chain.php @@ -0,0 +1,15 @@ +getPrevious(); +echo 'previous_is_exception=', ($prev instanceof Exception) ? 'true' : 'false', "\n"; +echo 'previous_message=', $prev instanceof Exception ? $prev->getMessage() : 'null', "\n"; +echo 'inner_previous_null=', (null === $inner->getPrevious()) ? 'true' : 'false', "\n"; + +$chain = (string) $outer; +echo 'chain_has_next=', (str_contains($chain, 'Next Exception')) ? 'true' : 'false', "\n"; +echo 'chain_has_inner=', (str_contains($chain, 'inner')) ? 'true' : 'false', "\n"; +echo 'chain_has_outer=', (str_contains($chain, 'outer')) ? 'true' : 'false', "\n";