You are here

public function EachPromiseTest::testDoesNotBlowStackWithRejectedPromises in Zircon Profile 8

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

File

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

Class

EachPromiseTest
@covers GuzzleHttp\Promise\EachPromise

Namespace

GuzzleHttp\Promise\Tests

Code

public function testDoesNotBlowStackWithRejectedPromises() {
  $pending = [];
  for ($i = 0; $i < 100; $i++) {
    $pending[] = new RejectedPromise($i);
  }
  $values = [];
  $each = new EachPromise($pending, [
    'rejected' => function ($value) use (&$values) {
      $values[] = $value;
    },
  ]);
  $called = false;
  $each
    ->promise()
    ->then(function () use (&$called) {
    $called = true;
  }, function () {
    $this
      ->fail('Should not have rejected.');
  });
  $this
    ->assertFalse($called);
  P\queue()
    ->run();
  $this
    ->assertTrue($called);
  $this
    ->assertEquals(range(0, 99), $values);
}