$this->
assertEquals(3,
$logger->
countErrors());
$logs =
$logger->
getLogs('critical'
);
$this->
assertCount(3,
$logs);
$this->
assertStringStartsWith('Uncaught PHP Exception Exception: "foo" at ErrorListenerTest.php line',
$logs[0
]);
$this->
assertStringStartsWith('Uncaught PHP Exception Exception: "foo" at ErrorListenerTest.php line',
$logs[1
]);
$this->
assertStringStartsWith('Exception thrown when handling an exception (RuntimeException: bar at ErrorListenerTest.php line',
$logs[2
]);
} public function testHandleWithLoggerAndCustomConfiguration() { $request =
new Request();
$event =
new ExceptionEvent(new TestKernel(),
$request, HttpKernelInterface::MAIN_REQUEST,
new \
RuntimeException('bar'
));
$logger =
new TestLogger();
$l =
new ErrorListener('not used',
$logger, false,
[ \RuntimeException::
class => [ 'log_level' => 'warning',
'status_code' => 401,
],
]);
$l->
logKernelException($event);
$l->
onKernelException($event);
$this->
assertEquals(new Response('foo', 401
),
$event->
getResponse());