| Total Complexity | 4 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class HandlerTest extends TestCase |
||
| 13 | { |
||
| 14 | /** @test */ |
||
| 15 | public function it_respects_is_contract(): void |
||
| 16 | { |
||
| 17 | $this->assertInstanceOf(HandlerContract::class, new Handler()); |
||
| 18 | } |
||
| 19 | |||
| 20 | /** @test */ |
||
| 21 | public function it_handles_an_exception(): void |
||
| 22 | { |
||
| 23 | $writerMock = $this->createMock(WriterContract::class); |
||
| 24 | $inspectorMock = $this->createMock(\Whoops\Exception\Inspector::class); |
||
| 25 | |||
| 26 | $writerMock->expects($this->once()) |
||
| 27 | ->method('write') |
||
| 28 | ->with($inspectorMock); |
||
| 29 | |||
| 30 | $handler = new Handler($writerMock); |
||
| 31 | |||
| 32 | $handler->setInspector($inspectorMock); |
||
| 33 | |||
| 34 | $this->assertEquals($handler->handle(), Handler::QUIT); |
||
| 35 | } |
||
| 36 | |||
| 37 | /** @test */ |
||
| 38 | public function it_sets_the_output(): void |
||
| 39 | { |
||
| 40 | $writerMock = $this->createMock(WriterContract::class); |
||
| 41 | $output = new ConsoleOutput(); |
||
| 42 | |||
| 43 | $writerMock->expects($this->once()) |
||
| 44 | ->method('setOutput') |
||
| 45 | ->with($output); |
||
| 46 | |||
| 47 | (new Handler($writerMock))->setOutput($output); |
||
| 48 | } |
||
| 49 | |||
| 50 | /** @test */ |
||
| 51 | public function it_gets_the_writer(): void |
||
| 52 | { |
||
| 53 | $writer = new Writer(); |
||
| 54 | $handler = new Handler($writer); |
||
| 55 | |||
| 56 | $this->assertEquals($handler->getWriter(), $writer); |
||
| 57 | } |
||
| 59 |