PromiseTestCancelThatRejectsAfterwardsShouldNotReportUnhandled.phpt 566 B

123456789101112131415161718192021222324
  1. --TEST--
  2. Calling cancel() that rejects afterwards should not report unhandled rejection
  3. --INI--
  4. # suppress legacy PHPUnit 7 warning for Xdebug 3
  5. xdebug.default_enable=
  6. --FILE--
  7. <?php
  8. use React\Promise\Promise;
  9. require __DIR__ . '/../vendor/autoload.php';
  10. /** @var callable(Throwable):void $reject */
  11. $promise = new Promise(function () { }, function ($_, callable $callback) use (&$reject) { $reject = $callback; });
  12. $promise->cancel();
  13. assert($reject instanceof \Closure);
  14. $reject(new \RuntimeException('Cancelled'));
  15. echo 'void' . PHP_EOL;
  16. ?>
  17. --EXPECT--
  18. void