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

LoggerBuilderIntegrationTest::testBuild()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace Graze\Monolog;
3
4
use Monolog\Logger;
5
6
class LoggerBuilderIntegrationTest 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 assertDefaultHandlers(Logger $logger)
0 ignored issues
show
introduced by
Function has parameters but no doc block
Loading history...
14
    {
15
        $handlers = array();
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
16
        do {
17
            try {
18
                $handlers[] = $handler = $logger->popHandler();
0 ignored issues
show
Unused Code introduced by
The assignment to $handler is dead and can be removed.
Loading history...
19
            } catch (\Exception $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
20
            }
21
        } while (!isset($e));
22
23
        $this->assertSame(array(), $handlers, 'There are more handlers defined than should be');
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
24
    }
25
26
    public function assertDefaultProcessors(Logger $logger)
0 ignored issues
show
introduced by
Function has parameters but no doc block
Loading history...
27
    {
28
        $processors = array();
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
29
        do {
30
            try {
31
                $processors[] = $processor = $logger->popProcessor();
0 ignored issues
show
Unused Code introduced by
The assignment to $processor is dead and can be removed.
Loading history...
32
            } catch (\Exception $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
33
            }
34
        } while (!isset($e));
35
36
        $this->assertInstanceOf('Graze\Monolog\Processor\ExceptionMessageProcessor', array_shift($processors));
37
        $this->assertInstanceOf('Graze\Monolog\Processor\EnvironmentProcessor', array_shift($processors));
38
        $this->assertInstanceOf('Graze\Monolog\Processor\HttpProcessor', array_shift($processors));
39
        $this->assertSame(array(), $processors, 'There are more processors defined than should be');
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
40
    }
41
42
    public function testBuild()
43
    {
44
        $logger = $this->builder->build();
45
46
        $this->assertSame(LoggerBuilder::DEFAULT_NAME, $logger->getName());
47
        $this->assertDefaultHandlers($logger);
48
        $this->assertDefaultProcessors($logger);
49
    }
50
}
51