1
0
mirror of https://github.com/danog/amp.git synced 2024-12-03 09:57:51 +01:00
amp/test/RethrowTest.php
Niklas Keller 2f778fe069 Use revolt
Removes deprecated APIs.
2021-03-26 22:34:32 +01:00

33 lines
698 B
PHP

<?php
namespace Amp\Test;
use Amp\Failure;
use Amp\PHPUnit\AsyncTestCase;
use Amp\Promise;
use Revolt\EventLoop\Loop;
use function Revolt\EventLoop\delay;
class RethrowTest extends AsyncTestCase
{
public function testRethrow(): void
{
$exception = new \Exception;
$promise = new Failure($exception);
Promise\rethrow($promise);
$invoked = false;
Loop::setErrorHandler(function (\Throwable $exception) use (&$invoked, &$reason): void {
$invoked = true;
$reason = $exception;
});
delay(0); // Tick the event loop.
self::assertTrue($invoked);
self::assertSame($reason, $exception);
}
}