|
9 | 9 | use Laravel\Octane\RequestContext; |
10 | 10 | use Laravel\Octane\Swoole\SwooleClient; |
11 | 11 | use Mockery; |
| 12 | +use Symfony\Component\HttpFoundation\StreamedResponse; |
12 | 13 |
|
13 | 14 | class SwooleClientTest extends TestCase |
14 | 15 | { |
@@ -133,6 +134,27 @@ public function test_respond_method_send_response_to_swoole() |
133 | 134 | ]), new OctaneResponse(new Response('Hello World', 200, ['Content-Type' => 'text/html']))); |
134 | 135 | } |
135 | 136 |
|
| 137 | + /** @doesNotPerformAssertions @test */ |
| 138 | + public function test_respond_method_send_streamed_response_to_swoole() |
| 139 | + { |
| 140 | + $client = new SwooleClient; |
| 141 | + |
| 142 | + $swooleResponse = Mockery::mock('Swoole\Http\Response'); |
| 143 | + |
| 144 | + $swooleResponse->shouldReceive('status')->once()->with(200); |
| 145 | + $swooleResponse->shouldReceive('header')->once()->with('Cache-Control', 'no-cache, private'); |
| 146 | + $swooleResponse->shouldReceive('header')->once()->with('Content-Type', 'text/html'); |
| 147 | + $swooleResponse->shouldReceive('header')->once()->with('Date', Mockery::type('string')); |
| 148 | + $swooleResponse->shouldReceive('write')->once()->with('Hello World'); |
| 149 | + $swooleResponse->shouldReceive('end')->once(); |
| 150 | + |
| 151 | + $client->respond(new RequestContext([ |
| 152 | + 'swooleResponse' => $swooleResponse, |
| 153 | + ]), new OctaneResponse(new StreamedResponse(function () { |
| 154 | + echo 'Hello World'; |
| 155 | + }, 200, ['Content-Type' => 'text/html']))); |
| 156 | + } |
| 157 | + |
136 | 158 | /** @doesNotPerformAssertions @test */ |
137 | 159 | public function test_error_method_sends_error_response_to_swoole() |
138 | 160 | { |
|
0 commit comments