|
|
|
@ -280,6 +280,30 @@ class FlightTest extends TestCase
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testStreamRoute()
|
|
|
|
|
{
|
|
|
|
|
$response_mock = new class extends Response {
|
|
|
|
|
public function setRealHeader(string $header_string, bool $replace = true, int $response_code = 0): Response
|
|
|
|
|
{
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
$mock_response_class_name = get_class($response_mock);
|
|
|
|
|
Flight::register('response', $mock_response_class_name);
|
|
|
|
|
Flight::route('/stream', function () {
|
|
|
|
|
echo 'stream';
|
|
|
|
|
})->stream();
|
|
|
|
|
Flight::request()->url = '/stream';
|
|
|
|
|
$this->expectOutputString('stream');
|
|
|
|
|
Flight::start();
|
|
|
|
|
$this->assertEquals('', Flight::response()->getBody());
|
|
|
|
|
$this->assertEquals([
|
|
|
|
|
'X-Accel-Buffering' => 'no',
|
|
|
|
|
'Connection' => 'close'
|
|
|
|
|
], Flight::response()->getHeaders());
|
|
|
|
|
$this->assertEquals(200, Flight::response()->status());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testStreamRouteWithHeaders()
|
|
|
|
|
{
|
|
|
|
|
$response_mock = new class extends Response {
|
|
|
|
|
public function setRealHeader(string $header_string, bool $replace = true, int $response_code = 0): Response
|
|
|
|
|