You are here

public function PromiseTest::testDoesNotBlowStackWhenWaitingOnNestedThens in Zircon Profile 8

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

File

vendor/guzzlehttp/promises/tests/PromiseTest.php, line 556

Class

PromiseTest
@covers GuzzleHttp\Promise\Promise

Namespace

GuzzleHttp\Promise\Tests

Code

public function testDoesNotBlowStackWhenWaitingOnNestedThens() {
  $inner = new Promise(function () use (&$inner) {
    $inner
      ->resolve(0);
  });
  $prev = $inner;
  for ($i = 1; $i < 100; $i++) {
    $prev = $prev
      ->then(function ($i) {
      return $i + 1;
    });
  }
  $parent = new Promise(function () use (&$parent, $prev) {
    $parent
      ->resolve($prev);
  });
  $this
    ->assertEquals(99, $parent
    ->wait());
}