Passed
Branch stable (668427)
by Nuno
04:13 queued 01:26
created

HandlerTest::it_gets_the_writer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Tests\Unit;
4
5
use PHPUnit\Framework\TestCase;
6
use NunoMaduro\Collision\Writer;
7
use NunoMaduro\Collision\Handler;
8
use Symfony\Component\Console\Output\ConsoleOutput;
9
use NunoMaduro\Collision\Contracts\Writer as WriterContract;
10
use NunoMaduro\Collision\Contracts\Handler as HandlerContract;
11
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
    }
58
}
59