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

ErrorHandlerBuilderIntegrationTest::setUp()   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
class ErrorHandlerBuilderIntegrationTest extends \PHPUnit_Framework_TestCase
5
{
6
    public function setUp()
7
    {
8
        $this->defaultErrorHandler = set_error_handler(function(){});
0 ignored issues
show
Bug Best Practice introduced by
The property defaultErrorHandler does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
9
        $this->defaultExceptionHandler = set_exception_handler(function(){});
0 ignored issues
show
Bug Best Practice introduced by
The property defaultExceptionHandler does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
10
        $this->tearDown();
11
12
        $this->builder = new ErrorHandlerBuilder();
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...
13
    }
14
15
    public function tearDown()
16
    {
17
        set_error_handler($this->defaultErrorHandler);
18
        set_exception_handler($this->defaultExceptionHandler);
19
    }
20
21
    public function testBuild()
22
    {
23
        $handler = $this->builder->build();
0 ignored issues
show
Unused Code introduced by
The assignment to $handler is dead and can be removed.
Loading history...
24
25
        $this->assertSame(set_error_handler(function(){}), $this->defaultErrorHandler);
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
26
        $this->assertSame(set_exception_handler(function(){}), $this->defaultExceptionHandler);
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
27
    }
28
29
    public function testBuildAndRegister()
30
    {
31
        $handler = $this->builder->buildAndRegister();
32
33
        $this->assertSame(set_error_handler(function(){}), array($handler, 'handleError'));
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
34
        $this->assertSame(set_exception_handler(function(){}), array($handler, 'handleException'));
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
35
    }
36
}
37