You are here

public function PromiseTest::testDoesNotForwardRejectedPromise in Zircon Profile 8

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

File

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

Class

PromiseTest
@covers GuzzleHttp\Promise\Promise

Namespace

GuzzleHttp\Promise\Tests

Code

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