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

LoggerBuilderTest   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 64
rs 10
c 0
b 0
f 0
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetHandlers() 0 3 1
A testSetName() 0 4 1
A testSetHandlers() 0 9 1
A testAddHandler() 0 6 1
A testSetProcessors() 0 9 1
A testGetProcessors() 0 3 1
A setUp() 0 3 1
A testGetName() 0 3 1
A testAddProcessor() 0 6 1
1
<?php
2
namespace Graze\Monolog;
3
4
use Mockery as m;
5
6
class LoggerBuilderTest extends \PHPUnit_Framework_TestCase
7
{
8
    public function setUp()
9
    {
10
        $this->builder = new LoggerBuilder();
0 ignored issues
show
Bug Best Practice introduced by
The property builder does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
11
    }
12
13
    public function testGetName()
14
    {
15
        $this->assertNull($this->builder->getName());
16
    }
17
18
    public function testSetName()
19
    {
20
        $this->builder->setName('foo');
21
        $this->assertSame('foo', $this->builder->getName());
22
    }
23
24
    public function testAddHandler()
25
    {
26
        $handler = m::mock('Monolog\Handler\HandlerInterface');
27
        $this->builder->addHandler($handler);
28
29
        $this->assertSame(array($handler), $this->builder->getHandlers());
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
30
    }
31
32
    public function testGetHandlers()
33
    {
34
        $this->assertSame(array(), $this->builder->getHandlers());
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
35
    }
36
37
    public function testSetHandlers()
38
    {
39
        $handlers = array(
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
40
            m::mock('Monolog\Handler\HandlerInterface'),
41
            m::mock('Monolog\Handler\HandlerInterface')
42
        );
43
44
        $this->builder->setHandlers($handlers);
45
        $this->assertSame($handlers, $this->builder->getHandlers());
46
    }
47
48
    public function testAddProcessor()
49
    {
50
        $processor = function(){};
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
51
        $this->builder->addProcessor($processor);
52
53
        $this->assertSame(array($processor), $this->builder->getProcessors());
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
54
    }
55
56
    public function testGetProcessors()
57
    {
58
        $this->assertSame(array(), $this->builder->getProcessors());
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
59
    }
60
61
    public function testSetProcessors()
62
    {
63
        $processors = array(
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
64
            function(){},
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
65
            function(){}
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
66
        );
67
68
        $this->builder->setProcessors($processors);
69
        $this->assertSame($processors, $this->builder->getProcessors());
70
    }
71
}
72