You are here

public function FunctionsTest::testCanWaitOnPromiseAfterFulfilled in Zircon Profile 8

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

File

vendor/guzzlehttp/promises/tests/functionsTest.php, line 623

Class

FunctionsTest

Namespace

GuzzleHttp\Promise\Tests

Code

public function testCanWaitOnPromiseAfterFulfilled() {
  $f = function () {
    static $i = 0;
    $i++;
    return $p = new P\Promise(function () use (&$p, $i) {
      $p
        ->resolve($i . '-bar');
    });
  };
  $promises = [];
  for ($i = 0; $i < 20; $i++) {
    $promises[] = $f();
  }
  $p = P\coroutine(function () use ($promises) {
    (yield new P\FulfilledPromise('foo!'));
    foreach ($promises as $promise) {
      (yield $promise);
    }
  });
  $this
    ->assertEquals('20-bar', $p
    ->wait());
}