1
0
mirror of https://github.com/danog/amp.git synced 2024-12-02 17:37:50 +01:00
amp/test/RethrowTest.php
2017-03-13 07:17:06 +01:00

49 lines
1.1 KiB
PHP

<?php
namespace Amp\Test;
use Amp;
use Amp\Failure;
use Amp\Loop;
use PHPUnit\Framework\TestCase;
use function React\Promise\reject;
class RethrowTest extends TestCase {
public function testRethrow() {
$exception = new \Exception;
try {
Loop::run(function () use ($exception) {
$promise = new Failure($exception);
Amp\rethrow($promise);
});
} catch (\Exception $reason) {
$this->assertSame($exception, $reason);
return;
}
$this->fail('Failed promise reason should be thrown from loop');
}
/**
* @depends testRethrow
*/
public function testReactPromise() {
$exception = new \Exception;
try {
Loop::run(function () use ($exception) {
$promise = reject($exception);
Amp\rethrow($promise);
});
} catch (\Exception $reason) {
$this->assertSame($exception, $reason);
return;
}
$this->fail('Failed promise reason should be thrown from loop');
}
}