public function FunctionsTest::testAsyncPromisesWithCorrectlyYieldedValues in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/guzzlehttp/promises/tests/functionsTest.php \GuzzleHttp\Promise\Tests\FunctionsTest::testAsyncPromisesWithCorrectlyYieldedValues()
File
- vendor/
guzzlehttp/ promises/ tests/ functionsTest.php, line 502
Class
Namespace
GuzzleHttp\Promise\TestsCode
public function testAsyncPromisesWithCorrectlyYieldedValues() {
$promises = [
new P\Promise(),
new P\Promise(),
new P\Promise(),
];
$promise = P\coroutine(function () use ($promises) {
$value = null;
$this
->assertEquals('skip', (yield new P\FulfilledPromise('skip')));
foreach ($promises as $idx => $p) {
$value = (yield $p);
$this
->assertEquals($value, $idx);
$this
->assertEquals('skip', (yield new P\FulfilledPromise('skip')));
}
$this
->assertEquals('skip', (yield new P\FulfilledPromise('skip')));
(yield $value);
});
$promises[0]
->resolve(0);
$promises[1]
->resolve(1);
$promises[2]
->resolve(2);
$promise
->then(function ($v) use (&$r) {
$r = $v;
});
P\queue()
->run();
$this
->assertEquals(2, $r);
}