You are here

public function EachPromiseTest::testInvokesAllPromises in Zircon Profile 8

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

File

vendor/guzzlehttp/promises/tests/EachPromiseTest.php, line 22

Class

EachPromiseTest
@covers GuzzleHttp\Promise\EachPromise

Namespace

GuzzleHttp\Promise\Tests

Code

public function testInvokesAllPromises() {
  $promises = [
    new Promise(),
    new Promise(),
    new Promise(),
  ];
  $called = [];
  $each = new EachPromise($promises, [
    'fulfilled' => function ($value) use (&$called) {
      $called[] = $value;
    },
  ]);
  $p = $each
    ->promise();
  $promises[0]
    ->resolve('a');
  $promises[1]
    ->resolve('c');
  $promises[2]
    ->resolve('b');
  P\queue()
    ->run();
  $this
    ->assertEquals([
    'a',
    'c',
    'b',
  ], $called);
  $this
    ->assertEquals(PromiseInterface::FULFILLED, $p
    ->getState());
}