Skip to content

Commit f8b9392

Browse files
committed
add test for async request fire events
1 parent fc0a4a7 commit f8b9392

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/Http/HttpClientTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,28 @@ public function testTheRequestSendingAndResponseReceivedEventsAreFiredWhenAReque
940940
m::close();
941941
}
942942

943+
public function testTheRequestSendingAndResponseReceivedEventsAreFiredWhenARequestIsSentAsync()
944+
{
945+
$events = m::mock(Dispatcher::class);
946+
$events->shouldReceive('dispatch')->times(5)->with(m::type(RequestSending::class));
947+
$events->shouldReceive('dispatch')->times(5)->with(m::type(ResponseReceived::class));
948+
949+
$factory = new Factory($events);
950+
$factory->fake();
951+
$factory->pool(function (Pool $pool) {
952+
return [
953+
$pool->get('https://example.com'),
954+
$pool->head('https://example.com'),
955+
$pool->post('https://example.com'),
956+
$pool->patch('https://example.com'),
957+
$pool->delete('https://example.com'),
958+
];
959+
});
960+
961+
962+
m::close();
963+
}
964+
943965
public function testTheTransferStatsAreCalledSafelyWhenFakingTheRequest()
944966
{
945967
$this->factory->fake(['https://example.com' => ['world' => 'Hello world']]);

0 commit comments

Comments
 (0)