You are here

public function PromiseTest::testForwardsHandlersWhenRejectedPromiseIsReturned in Zircon Profile 8

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

File

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

Class

PromiseTest
@covers GuzzleHttp\Promise\Promise

Namespace

GuzzleHttp\Promise\Tests

Code

public function testForwardsHandlersWhenRejectedPromiseIsReturned() {
  $res = [];
  $p = new Promise();
  $p2 = new Promise();
  $p2
    ->reject('foo');
  $p2
    ->then(null, function ($v) use (&$res) {
    $res[] = 'A:' . $v;
  });
  $p
    ->then(null, function () use ($p2, &$res) {
    $res[] = 'B';
    return $p2;
  })
    ->then(null, function ($v) use (&$res) {
    $res[] = 'C:' . $v;
  });
  $p
    ->reject('a');
  $p
    ->then(null, function ($v) use (&$res) {
    $res[] = 'D:' . $v;
  });
  P\queue()
    ->run();
  $this
    ->assertEquals([
    'A:foo',
    'B',
    'D:a',
    'C:foo',
  ], $res);
}