You are here

public function PromiseTest::testRecursivelyForwardsWhenNotInstanceOfPromise in Zircon Profile 8

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

File

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

Class

PromiseTest
@covers GuzzleHttp\Promise\Promise

Namespace

GuzzleHttp\Promise\Tests

Code

public function testRecursivelyForwardsWhenNotInstanceOfPromise() {
  $res = [];
  $p = new Promise();
  $p2 = new NotPromiseInstance();
  $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([
    'B',
    'D:a',
  ], $res);
  $p2
    ->resolve('foo');
  P\queue()
    ->run();
  $this
    ->assertEquals([
    'B',
    'D:a',
    'A:foo',
    'C:foo',
  ], $res);
}