You are here

public function FunctionsTest::testCanCatchAndYieldOtherException in Zircon Profile 8

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

File

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

Class

FunctionsTest

Namespace

GuzzleHttp\Promise\Tests

Code

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