Skip to content

Commit

Permalink
Use generator
Browse files Browse the repository at this point in the history
  • Loading branch information
jenky committed Jul 2, 2023
1 parent 7d14669 commit b544ae6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/ReactPoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ public function test_react_sending_lots_of_requests(): void
})
);

for ($i=0; $i < 100; $i++) {
$requests[] = new AkamaiTileRequest($i);
}
$requests = static function (int $total) {
for ($i=1; $i <= $total; $i++) {
yield new AkamaiTileRequest($i);
}
};

$responses = (new Pool($connector))->send($requests);
$responses = (new Pool($connector))->send($requests(100));
$this->assertCount(100, $responses);
$this->assertInstanceOf(Response::class, $responses[0]);
$this->assertSame('bar', $responses[0]->header('X-Foo'));
Expand Down

0 comments on commit b544ae6

Please sign in to comment.