FunctionSetRejectionHandlerShouldBeInvokedForUnhandled.phpt 572 B

12345678910111213141516171819202122232425
  1. --TEST--
  2. The callback given to set_rejection_handler() should be invoked 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. echo 'Unhandled ' . get_class($e) . ': ' . $e->getMessage() . PHP_EOL;
  13. });
  14. reject(new RuntimeException('foo'));
  15. echo 'done' . PHP_EOL;
  16. ?>
  17. --EXPECT--
  18. Unhandled RuntimeException: foo
  19. done