You are here

public function PromiseTest::testRemovesReferenceFromChildWhenParentWaitedUpon in Zircon Profile 8

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

File

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

Class

PromiseTest
@covers GuzzleHttp\Promise\Promise

Namespace

GuzzleHttp\Promise\Tests

Code

public function testRemovesReferenceFromChildWhenParentWaitedUpon() {
  $r = null;
  $p = new Promise(function () use (&$p) {
    $p
      ->resolve('a');
  });
  $p2 = new Promise(function () use (&$p2) {
    $p2
      ->resolve('b');
  });
  $pb = $p
    ->then(function ($v) use ($p2, &$r) {
    $r = $v;
    return $p2;
  })
    ->then(function ($v) {
    return $v . '.';
  });
  $this
    ->assertEquals('a', $p
    ->wait());
  $this
    ->assertEquals('b', $p2
    ->wait());
  $this
    ->assertEquals('b.', $pb
    ->wait());
  $this
    ->assertEquals('a', $r);
}