TXT;
$chunk =
new DataChunk(0,
$data);
$response =
new MockResponse('',
['canceled' => false, 'http_method' => 'GET', 'url' => 'http://localhost:8080/events', 'response_headers' =>
['content-type: text/event-stream'
]]);
$responseStream =
new ResponseStream((function D
) use ($response,
$chunk) { yield $response =>
new FirstChunk();
yield $response =>
$chunk;
yield $response =>
new ErrorChunk(0, 'timeout'
);
})());
$hasCorrectHeaders =
function D
$options) { $this->
assertSame(['Accept: text/event-stream', 'Cache-Control: no-cache'
],
$options['headers'
]);
return true;
};
$httpClient =
$this->
createMock(HttpClientInterface::
class);
$httpClient->
method('request'
)->
with('GET', 'http://localhost:8080/events',
$this->
callback($hasCorrectHeaders))->
willReturn($response);