public function EachPromiseTest::testDoesNotCallNextOnIteratorUntilNeededWhenWaiting in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/guzzlehttp/promises/tests/EachPromiseTest.php \GuzzleHttp\Promise\Tests\EachPromiseTest::testDoesNotCallNextOnIteratorUntilNeededWhenWaiting()
File
- vendor/
guzzlehttp/ promises/ tests/ EachPromiseTest.php, line 236
Class
Namespace
GuzzleHttp\Promise\TestsCode
public function testDoesNotCallNextOnIteratorUntilNeededWhenWaiting() {
$results = [];
$values = [
10,
];
$remaining = 9;
$iter = function () use (&$values) {
while ($value = array_pop($values)) {
(yield $value);
}
};
$each = new EachPromise($iter(), [
'concurrency' => 1,
'fulfilled' => function ($r) use (&$results, &$values, &$remaining) {
$results[] = $r;
if ($remaining > 0) {
$values[] = $remaining--;
}
},
]);
$each
->promise()
->wait();
$this
->assertEquals(range(10, 1), $results);
}