Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 20 |
ErrorHandler | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
56 | |
0.00% |
0 / 20 |
handle() | |
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 7 |
|||
anonymous function () | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 6 |
|||
getSubscribedEvents() | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 6 |
<?php | |
namespace Codeception\Subscriber; | |
use \Symfony\Component\EventDispatcher\EventSubscriberInterface; | |
class ErrorHandler implements EventSubscriberInterface | |
{ | |
public function handle() { | |
error_reporting(E_ERROR | E_PARSE); | |
set_error_handler(function ($errno, $errstr, $errfile, $errline ) { | |
if (strpos($errstr, 'Cannot modify header information')!==false) return false; | |
if ($errno > 8) throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); | |
} | |
); | |
register_shutdown_function(function () { | |
$error = error_get_last(); | |
if (!is_array($error)) return; | |
echo "\n\n\nFATAL ERROR OCCURRED. TESTS NOT FINISHED.\n"; | |
echo sprintf("%s \nin %s:%d\n", $error['message'], $error['file'], $error['line']); | |
}); | |
} | |
static function getSubscribedEvents() | |
{ | |
return array( | |
'suite.before' => 'handle' | |
); | |
} | |
} |