You are here

public function FunctionsTest::testCanCatchAndThrowOtherException in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/promises/tests/functionsTest.php \GuzzleHttp\Promise\Tests\FunctionsTest::testCanCatchAndThrowOtherException()

File

vendor/guzzlehttp/promises/tests/functionsTest.php, line 408

Class

FunctionsTest

Namespace

GuzzleHttp\Promise\Tests

Code

public function testCanCatchAndThrowOtherException() {
  $promise = P\coroutine(function () {
    try {
      (yield new P\RejectedPromise('a'));
      $this
        ->fail('Should have thrown into the coroutine!');
    } catch (P\RejectionException $e) {
      throw new \Exception('foo');
    }
  });
  $promise
    ->otherwise(function ($value) use (&$result) {
    $result = $value;
  });
  P\queue()
    ->run();
  $this
    ->assertEquals(P\PromiseInterface::REJECTED, $promise
    ->getState());
  $this
    ->assertContains('foo', $result
    ->getMessage());
}