You are here

public function FunctionsTest::testCoroutineOtherwiseIntegrationTest in Zircon Profile 8

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

File

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

Class

FunctionsTest

Namespace

GuzzleHttp\Promise\Tests

Code

public function testCoroutineOtherwiseIntegrationTest() {
  $a = new P\Promise();
  $b = new P\Promise();
  $promise = P\coroutine(function () use ($a, $b) {

    // Execute the pool of commands concurrently, and process errors.
    (yield $a);
    (yield $b);
  })
    ->otherwise(function (\Exception $e) {

    // Throw errors from the operations as a specific Multipart error.
    throw new \OutOfBoundsException('a', 0, $e);
  });
  $a
    ->resolve('a');
  $b
    ->reject('b');
  $reason = P\inspect($promise)['reason'];
  $this
    ->assertInstanceOf('OutOfBoundsException', $reason);
  $this
    ->assertInstanceOf('GuzzleHttp\\Promise\\RejectionException', $reason
    ->getPrevious());
}