You are here

public function PromiseTest::testRecursivelyForwardsWhenOnlyThennable in Zircon Profile 8

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

File

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

Class

PromiseTest
@covers GuzzleHttp\Promise\Promise

Namespace

GuzzleHttp\Promise\Tests

Code

public function testRecursivelyForwardsWhenOnlyThennable() {
  $res = [];
  $p = new Promise();
  $p2 = new Thennable();
  $p2
    ->resolve('foo');
  $p2
    ->then(function ($v) use (&$res) {
    $res[] = 'A:' . $v;
  });
  $p
    ->then(function () use ($p2, &$res) {
    $res[] = 'B';
    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([
    'A:foo',
    'B',
    'D:a',
    'C:foo',
  ], $res);
}