| 1 | <?php declare(strict_types = 1); |
||
| 6 | class ErrorHandlerMiddlewareTest extends PHPUnit_Framework_TestCase |
||
| 7 | { |
||
| 8 | |||
| 9 | public function tearDown() |
||
| 10 | { |
||
| 11 | Mockery::close(); |
||
| 12 | } |
||
| 13 | |||
| 14 | public function testHandle() |
||
| 15 | { |
||
| 16 | $this->markTestSkipped(); |
||
| 17 | |||
| 18 | $e = new Exception('Message'); |
||
| 19 | $run = Mockery::mock(\Whoops\RunInterface::class); |
||
| 20 | $run->shouldReceive('allowQuit')->with(false); |
||
| 21 | $run->shouldReceive('sendHttpCode')->with(false); |
||
| 22 | $run->shouldReceive('writeToOutput')->with(false); |
||
| 23 | $run->shouldReceive('handleException')->with($e)->andReturn($e->getMessage()); |
||
| 24 | $responseFactory = Mockery::mock(\Venta\Http\Factory\ResponseFactory::class); |
||
| 25 | $responseFactory->shouldReceive('createResponse') |
||
| 26 | ->with(500) |
||
| 27 | ->andReturn(new \Venta\Http\Response('php://memory', 500)); |
||
| 28 | $middleware = new \Venta\Framework\ErrorHandler\ErrorHandlerMiddleware($run, $responseFactory); |
||
| 29 | $request = Mockery::mock(\Venta\Contracts\Http\Request::class); |
||
| 30 | $result = $middleware->handle($request, function () use ($e) { |
||
| 31 | throw $e; |
||
| 32 | }); |
||
| 33 | $this->assertEquals($e->getMessage(), $result->getBody()->__toString()); |
||
| 34 | $this->assertEquals(500, $result->getStatusCode()); |
||
| 35 | } |
||
| 36 | |||
| 37 | } |
||
| 38 | |||
| 39 | } |