You are here

public function FunctionsTest::testCanAsyncReject in Zircon Profile 8

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

File

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

Class

FunctionsTest

Namespace

GuzzleHttp\Promise\Tests

Code

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