public function EachPromiseTest::testCanResolveBeforeConsumingAll in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/guzzlehttp/promises/tests/EachPromiseTest.php \GuzzleHttp\Promise\Tests\EachPromiseTest::testCanResolveBeforeConsumingAll()
File
- vendor/
guzzlehttp/ promises/ tests/ EachPromiseTest.php, line 54
Class
Namespace
GuzzleHttp\Promise\TestsCode
public function testCanResolveBeforeConsumingAll() {
$called = 0;
$a = new Promise(function () use (&$a) {
$a
->resolve('a');
});
$b = new Promise(function () {
$this
->fail();
});
$each = new EachPromise([
$a,
$b,
], [
'fulfilled' => function ($value, $idx, Promise $aggregate) use (&$called) {
$this
->assertSame($idx, 0);
$this
->assertEquals('a', $value);
$aggregate
->resolve(null);
$called++;
},
'rejected' => function (\Exception $reason) {
$this
->fail($reason
->getMessage());
},
]);
$p = $each
->promise();
$p
->wait();
$this
->assertNull($p
->wait());
$this
->assertEquals(1, $called);
$this
->assertEquals(PromiseInterface::FULFILLED, $a
->getState());
$this
->assertEquals(PromiseInterface::PENDING, $b
->getState());
// Resolving $b has no effect on the aggregate promise.
$b
->resolve('foo');
$this
->assertEquals(1, $called);
}