You are here

public function FunctionsTest::testAnyReturnsFirstMatch in Zircon Profile 8

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

File

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

Class

FunctionsTest

Namespace

GuzzleHttp\Promise\Tests

Code

public function testAnyReturnsFirstMatch() {
  $a = new Promise();
  $b = new Promise();
  $c = \GuzzleHttp\Promise\any([
    $a,
    $b,
  ]);
  $b
    ->resolve('b');
  $a
    ->resolve('a');

  //P\queue()->run();

  //$this->assertEquals('fulfilled', $c->getState());
  $c
    ->then(function ($value) use (&$result) {
    $result = $value;
  });
  P\queue()
    ->run();
  $this
    ->assertEquals('b', $result);
}