1
0
mirror of https://github.com/danog/amp.git synced 2024-12-11 00:49:48 +01:00
amp/test/FailureTest.php

27 lines
492 B
PHP
Raw Normal View History

<?php
2016-07-12 18:20:06 +02:00
namespace Amp\Test;
use Amp\Failure;
2020-09-28 05:19:52 +02:00
use Amp\PHPUnit\AsyncTestCase;
use function Amp\await;
2016-07-12 18:20:06 +02:00
2020-09-28 05:19:52 +02:00
class FailureTest extends AsyncTestCase
2018-06-18 20:00:01 +02:00
{
2020-09-28 05:19:52 +02:00
public function testOnResolve(): void
2018-06-18 20:00:01 +02:00
{
2016-07-12 18:20:06 +02:00
$exception = new \Exception;
$failure = new Failure($exception);
2016-07-12 18:20:06 +02:00
2020-09-28 05:19:52 +02:00
try {
await($failure);
} catch (\Exception $reason) {
2021-03-26 22:34:32 +01:00
self::assertSame($exception, $reason);
2020-09-28 05:19:52 +02:00
return;
}
2016-07-12 18:20:06 +02:00
2021-03-26 22:34:32 +01:00
self::fail("Promise was not failed");
2016-07-12 18:20:06 +02:00
}
}