You are here

public function FunctionsTest::testCanRejectFromRejectionCallback in Zircon Profile 8

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

File

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

Class

FunctionsTest

Namespace

GuzzleHttp\Promise\Tests

Code

public function testCanRejectFromRejectionCallback() {
  $promise = P\coroutine(function () {
    (yield new P\FulfilledPromise(0));
    (yield new P\RejectedPromise('no!'));
  });
  $promise
    ->then(function () {
    $this
      ->fail();
  }, function ($reason) use (&$result) {
    $result = $reason;
  });
  P\queue()
    ->run();
  $this
    ->assertInstanceOf('GuzzleHttp\\Promise\\RejectionException', $result);
  $this
    ->assertEquals('no!', $result
    ->getReason());
}