Skip to content

Commit d618180

Browse files
author
Tom Mitchelmore
committed
Include E_NOTICE and E_WARNING in default report-only error levels
1 parent 1bf56b8 commit d618180

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

src/Bootstrappers/RegisterExceptionHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ public function handleError($level, $message, $file = '', $line = 0, $context =
9797
$exception = new ErrorException($message, 0, $level, $file, $line);
9898

9999
$errorsToReportOnly = $this->app->get('config')->get('app.errors.reportOnly') ?: [
100+
E_NOTICE,
101+
E_WARNING,
100102
E_USER_NOTICE,
101103
E_USER_DEPRECATED,
102104
E_DEPRECATED

tests/Unit/Bootstrappers/RegisterExceptionHandlerTest.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,52 @@ public function errors_are_converted_to_exceptions()
4242
$bootstrapper->handleError(E_USER_ERROR, 'Test Error');
4343
}
4444

45+
/**
46+
* @test
47+
*/
48+
public function E_NOTICE_errors_are_not_converted_to_exceptions()
49+
{
50+
Functions\expect('is_admin')->once()->andReturn(false);
51+
52+
$app = new Application;
53+
$handler = Mockery::mock(HandlerInterface::class);
54+
$app->bind(HandlerInterface::class, $handler);
55+
$config = new Config();
56+
$app->bind('config', $config);
57+
$app->bind(Config::class, $config);
58+
59+
$handler->shouldReceive('report')->once()->with(Mockery::on(function ($e) {
60+
return $e->getSeverity() === E_NOTICE && $e->getMessage() === 'Test Error';
61+
}));
62+
63+
$bootstrapper = new RegisterExceptionHandler();
64+
$bootstrapper->bootstrap($app);
65+
$bootstrapper->handleError(E_NOTICE, 'Test Error');
66+
}
67+
68+
/**
69+
* @test
70+
*/
71+
public function E_WARNING_errors_are_not_converted_to_exceptions()
72+
{
73+
Functions\expect('is_admin')->once()->andReturn(false);
74+
75+
$app = new Application;
76+
$handler = Mockery::mock(HandlerInterface::class);
77+
$app->bind(HandlerInterface::class, $handler);
78+
$config = new Config();
79+
$app->bind('config', $config);
80+
$app->bind(Config::class, $config);
81+
82+
$handler->shouldReceive('report')->once()->with(Mockery::on(function ($e) {
83+
return $e->getSeverity() === E_WARNING && $e->getMessage() === 'Test Error';
84+
}));
85+
86+
$bootstrapper = new RegisterExceptionHandler();
87+
$bootstrapper->bootstrap($app);
88+
$bootstrapper->handleError(E_WARNING, 'Test Error');
89+
}
90+
4591
/**
4692
* @test
4793
*/

0 commit comments

Comments
 (0)