Passed
Push — master ( ddd97a...25aa58 )
by Harry
06:46
created

WhoopsHandlerTest::testConstruct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Graze\Monolog\Handler;
3
4
use Mockery as m;
5
use Monolog\TestCase;
6
7
class WhoopsHandlerTest extends TestCase
8
{
9
    public function setUp()
10
    {
11
        if (!interface_exists('Whoops\Handler\HandlerInterface', true)) {
12
            $this->markTestSkipped('filp/whoops not installed');
13
        }
14
        
15
        $this->handlerWhoops = m::mock('Whoops\Handler\HandlerInterface');
0 ignored issues
show
Bug Best Practice introduced by
The property handlerWhoops does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
16
    }
17
18
    public function testConstruct()
19
    {
20
        $this->assertInstanceOf('Graze\\Monolog\\Handler\\WhoopsHandler', new WhoopsHandler($this->handlerWhoops));
21
    }
22
23
    public function testInterface()
24
    {
25
        $this->assertInstanceOf('Monolog\\Handler\\HandlerInterface', new WhoopsHandler($this->handlerWhoops));
26
    }
27
28
    public function testHandleError()
29
    {
30
        $record = $this->getRecord(300, 'test', array('file' => 'bar', 'line' => 1));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
31
        
32
        $formatter = m::mock('Monolog\\Formatter\\FormatterInterface');
0 ignored issues
show
Unused Code introduced by
The assignment to $formatter is dead and can be removed.
Loading history...
33
        
34
        $handlerMonolog = new WhoopsHandler($this->handlerWhoops);
35
             
36
        $this->handlerWhoops
37
            ->shouldReceive('setInspector')
38
            ->once()
39
            ->with(m::type('Whoops\Exception\Inspector'));
40
              
41
        $this->handlerWhoops
42
            ->shouldReceive('setRun')
43
            ->once()
44
            ->with(m::type('Whoops\Run'));
45
               
46
        $this->handlerWhoops
47
            ->shouldReceive('setException')
48
            ->once()
49
            ->with(m::type('Whoops\Exception\ErrorException'));
50
             
51
        $this->handlerWhoops
52
            ->shouldReceive('handle')
53
            ->once();
54
             
55
        $handlerMonolog->handle($record);
56
    }
57
58
    public function testHandleException()
59
    {
60
        $exception = new \Whoops\Exception\ErrorException('foo');
61
        
62
        $record = $this->getRecord(300, 'foo', array('exception' => $exception));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
63
        
64
        $formatter = m::mock('Monolog\\Formatter\\FormatterInterface');
0 ignored issues
show
Unused Code introduced by
The assignment to $formatter is dead and can be removed.
Loading history...
65
        
66
        $handlerMonolog = new WhoopsHandler($this->handlerWhoops);
67
             
68
        $this->handlerWhoops
69
            ->shouldReceive('setInspector')
70
            ->once()
71
            ->with(m::type('Whoops\Exception\Inspector'));
72
              
73
        $this->handlerWhoops
74
            ->shouldReceive('setRun')
75
            ->once()
76
            ->with(m::type('Whoops\Run'));
77
               
78
        $this->handlerWhoops
79
            ->shouldReceive('setException')
80
            ->once()
81
            ->with($exception);
82
             
83
        $this->handlerWhoops
84
            ->shouldReceive('handle')
85
            ->once();
86
             
87
        $handlerMonolog->handle($record);
88
    }
89
}
90