You are here

public function FunctionsTest::testWaitsOnAllPromisesIntoArray in Zircon Profile 8

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

File

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

Class

FunctionsTest

Namespace

GuzzleHttp\Promise\Tests

Code

public function testWaitsOnAllPromisesIntoArray() {
  $e = new \Exception();
  $a = new Promise(function () use (&$a) {
    $a
      ->resolve('a');
  });
  $b = new Promise(function () use (&$b) {
    $b
      ->reject('b');
  });
  $c = new Promise(function () use (&$c, $e) {
    $c
      ->reject($e);
  });
  $results = \GuzzleHttp\Promise\inspect_all([
    $a,
    $b,
    $c,
  ]);
  $this
    ->assertEquals([
    [
      'state' => 'fulfilled',
      'value' => 'a',
    ],
    [
      'state' => 'rejected',
      'reason' => 'b',
    ],
    [
      'state' => 'rejected',
      'reason' => $e,
    ],
  ], $results);
}