You are here

public function EachPromiseTest::testIsWaitable in Zircon Profile 8.0

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

File

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

Class

EachPromiseTest
@covers GuzzleHttp\Promise\EachPromise

Namespace

GuzzleHttp\Promise\Tests

Code

public function testIsWaitable() {
  $a = new Promise(function () use (&$a) {
    $a
      ->resolve('a');
  });
  $b = new Promise(function () use (&$b) {
    $b
      ->resolve('b');
  });
  $called = [];
  $each = new EachPromise([
    $a,
    $b,
  ], [
    'fulfilled' => function ($value) use (&$called) {
      $called[] = $value;
    },
  ]);
  $p = $each
    ->promise();
  $this
    ->assertNull($p
    ->wait());
  $this
    ->assertEquals(PromiseInterface::FULFILLED, $p
    ->getState());
  $this
    ->assertEquals([
    'a',
    'b',
  ], $called);
}