Passed
Branch master (e8fd46)
by Alexey
03:15
created

ErrorHandlerMiddlewareTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 8

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 8
1
<?php declare(strict_types = 1);
2
3
namespace
4
{
5
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
}