From b635a16789be20a26b1d022fed3ba6126ab87f09 Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Fri, 24 Jun 2022 12:55:08 +0200 Subject: [PATCH] add test on uninstallation of exception filter --- tests/exception_filter_005.phpt | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/exception_filter_005.phpt diff --git a/tests/exception_filter_005.phpt b/tests/exception_filter_005.phpt new file mode 100644 index 0000000..7813691 --- /dev/null +++ b/tests/exception_filter_005.phpt @@ -0,0 +1,53 @@ +--TEST-- +Test V8::setExceptionFilter() : Uninstall filter on NULL +--SKIPIF-- + +--FILE-- +setExceptionFilter(function (Throwable $ex) { + echo "exception filter called.\n"; + return "moep"; +}); + +$v8->executeString(' + try { + PHP.throwException("Oops"); + } + catch (e) { + var_dump(e); + } +', null, V8Js::FLAG_PROPAGATE_PHP_EXCEPTIONS); + +$v8->setExceptionFilter(null); + +try { + $v8->executeString(' + try { + PHP.throwException("Oops"); + print("done\\n"); + } + catch (e) { + print("caught\\n"); + var_dump(e.getMessage()); + } + ', null, V8Js::FLAG_PROPAGATE_PHP_EXCEPTIONS); +} catch (Exception $ex) { + echo "caught in php: " . $ex->getMessage() . PHP_EOL; +} + +?> +===EOF=== +--EXPECT-- +exception filter called. +string(4) "moep" +caught +string(4) "Oops" +===EOF===