1
0
mirror of https://github.com/danog/amp.git synced 2024-12-11 17:09:40 +01:00
amp/test/RethrowTest.php
Aaron Piotrowski 7612ef3f1e
Drop direct conversion of React promises
React promises are still supported using Amp\Promise\adapt().
2020-10-30 10:19:12 -05:00

33 lines
674 B
PHP

<?php
namespace Amp\Test;
use Amp\Failure;
use Amp\Loop;
use Amp\PHPUnit\AsyncTestCase;
use Amp\Promise;
use function Amp\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.
$this->assertTrue($invoked);
$this->assertSame($reason, $exception);
}
}