You are here

public function PromiseTest::testForwardsReturnedRejectedPromisesDownChainBetweenGaps in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/guzzlehttp/promises/tests/PromiseTest.php \GuzzleHttp\Promise\Tests\PromiseTest::testForwardsReturnedRejectedPromisesDownChainBetweenGaps()

File

vendor/guzzlehttp/promises/tests/PromiseTest.php, line 401

Class

PromiseTest
@covers GuzzleHttp\Promise\Promise

Namespace

GuzzleHttp\Promise\Tests

Code

public function testForwardsReturnedRejectedPromisesDownChainBetweenGaps() {
  $p = new Promise();
  $rejected = new RejectedPromise('bar');
  $r = $r2 = null;
  $p
    ->then(null, null)
    ->then(null, function ($v) use (&$r, $rejected) {
    $r = $v;
    return $rejected;
  })
    ->then(null, function ($v) use (&$r2) {
    $r2 = $v;
  });
  $p
    ->reject('foo');
  P\queue()
    ->run();
  $this
    ->assertEquals('foo', $r);
  $this
    ->assertEquals('bar', $r2);
  try {
    $p
      ->wait();
  } catch (RejectionException $e) {
    $this
      ->assertEquals('foo', $e
      ->getReason());
  }
}