You are here

public function FunctionsTest::testSettleFulfillsWithFulfilledAndRejected in Zircon Profile 8

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

File

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

Class

FunctionsTest

Namespace

GuzzleHttp\Promise\Tests

Code

public function testSettleFulfillsWithFulfilledAndRejected() {
  $a = new Promise();
  $b = new Promise();
  $c = new Promise();
  $d = \GuzzleHttp\Promise\settle([
    $a,
    $b,
    $c,
  ]);
  $b
    ->resolve('b');
  $c
    ->resolve('c');
  $a
    ->reject('a');
  P\queue()
    ->run();
  $this
    ->assertEquals('fulfilled', $d
    ->getState());
  $d
    ->then(function ($value) use (&$result) {
    $result = $value;
  });
  P\queue()
    ->run();
  $this
    ->assertEquals([
    [
      'state' => 'rejected',
      'reason' => 'a',
    ],
    [
      'state' => 'fulfilled',
      'value' => 'b',
    ],
    [
      'state' => 'fulfilled',
      'value' => 'c',
    ],
  ], $result);
}