ErrorHandlerBuilderIntegrationTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 4 1
A testBuildAndRegister() 0 8 1
A setUp() 0 9 1
A testBuild() 0 8 1
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...
9
        });
10
        $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...
11
        });
12
        $this->tearDown();
13
14
        $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...
15
    }
16
17
    public function tearDown()
18
    {
19
        set_error_handler($this->defaultErrorHandler);
20
        set_exception_handler($this->defaultExceptionHandler);
21
    }
22
23
    public function testBuild()
24
    {
25
        $handler = $this->builder->build();
0 ignored issues
show
Unused Code introduced by
The assignment to $handler is dead and can be removed.
Loading history...
26
27
        $this->assertSame(set_error_handler(function () {
28
        }), $this->defaultErrorHandler);
29
        $this->assertSame(set_exception_handler(function () {
30
        }), $this->defaultExceptionHandler);
31
    }
32
33
    public function testBuildAndRegister()
34
    {
35
        $handler = $this->builder->buildAndRegister();
36
37
        $this->assertSame(set_error_handler(function () {
38
        }), [$handler, 'handleError']);
39
        $this->assertSame(set_exception_handler(function () {
40
        }), [$handler, 'handleException']);
41
    }
42
}
43