FunctionSetRejectionHandlerThatHasUnhandledShouldReportUnhandled.phpt 792 B

123456789101112131415161718192021222324252627282930
  1. --TEST--
  2. The callback given to set_rejection_handler() should be invoked for outer unhandled rejection but should use default rejection handler for unhandled rejection
  3. --INI--
  4. # suppress legacy PHPUnit 7 warning for Xdebug 3
  5. xdebug.default_enable=
  6. --FILE--
  7. <?php
  8. use function React\Promise\reject;
  9. use function React\Promise\set_rejection_handler;
  10. require __DIR__ . '/../vendor/autoload.php';
  11. set_rejection_handler(function (Throwable $e): void {
  12. reject(new \UnexpectedValueException('bar'));
  13. echo 'Unhandled ' . get_class($e) . ': ' . $e->getMessage() . PHP_EOL;
  14. });
  15. reject(new RuntimeException('foo'));
  16. echo 'done' . PHP_EOL;
  17. ?>
  18. --EXPECTF--
  19. Unhandled promise rejection with UnexpectedValueException: bar in %s:%d
  20. Stack trace:
  21. #0 %A{main}
  22. Unhandled RuntimeException: foo
  23. done