|
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
|
|
|
|