ErrorHandlerTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
cbo 2
dl 0
loc 43
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testHandle() 0 7 1
A testHandleXdebug() 0 13 3
A testHandleException() 0 6 1
A testRegister() 0 5 1
1
<?php
2
3
namespace Bowerphp\Test\Util;
4
5
use Bowerphp\Test\BowerphpTestCase;
6
use Bowerphp\Util\ErrorHandler;
7
8
class ErrorHandlerTest extends BowerphpTestCase
9
{
10
    public function testHandle()
11
    {
12
        $oldErrorReporting = error_reporting(0);
13
        $null = ErrorHandler::handle(1, 'foo', 'bar', 42);
14
        $this->assertNull($null);
15
        error_reporting($oldErrorReporting);
16
    }
17
18
    /**
19
     * @expectedException \ErrorException
20
     */
21
    public function testHandleXdebug()
22
    {
23
        if (!function_exists('xdebug_enable')) {
24
            $this->markTestSkipped('No xdebug');
25
        }
26
27
        $originalSet = ini_get('xdebug.scream');
28
        if (!$originalSet) {
29
            ini_set('xdebug.scream', true);
30
        }
31
        ErrorHandler::handle(1, 'foo', 'bar', 42);
32
        ini_set('xdebug.scream', $originalSet);
33
    }
34
35
    /**
36
     * @expectedException \ErrorException
37
     */
38
    public function testHandleException()
39
    {
40
        $oldErrorReporting = error_reporting(1);
41
        ErrorHandler::handle(1, 'foo', 'bar', 42);
42
        error_reporting($oldErrorReporting);
43
    }
44
45
    public function testRegister()
46
    {
47
        ErrorHandler::register();
48
        $this->assertTrue(true);    // jsut avoid risky test
49
    }
50
}
51