Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Bootstrappers/RegisterExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public function handleError($level, $message, $file = '', $line = 0, $context =
$exception = new ErrorException($message, 0, $level, $file, $line);

$errorsToReportOnly = $this->app->get('config')->get('app.errors.reportOnly') ?: [
E_NOTICE,
E_WARNING,
E_USER_NOTICE,
E_USER_DEPRECATED,
E_DEPRECATED
Expand Down
46 changes: 46 additions & 0 deletions tests/Unit/Bootstrappers/RegisterExceptionHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,52 @@ public function errors_are_converted_to_exceptions()
$bootstrapper->handleError(E_USER_ERROR, 'Test Error');
}

/**
* @test
*/
public function E_NOTICE_errors_are_not_converted_to_exceptions()
{
Functions\expect('is_admin')->once()->andReturn(false);

$app = new Application;
$handler = Mockery::mock(HandlerInterface::class);
$app->bind(HandlerInterface::class, $handler);
$config = new Config();
$app->bind('config', $config);
$app->bind(Config::class, $config);

$handler->shouldReceive('report')->once()->with(Mockery::on(function ($e) {
return $e->getSeverity() === E_NOTICE && $e->getMessage() === 'Test Error';
}));

$bootstrapper = new RegisterExceptionHandler();
$bootstrapper->bootstrap($app);
$bootstrapper->handleError(E_NOTICE, 'Test Error');
}

/**
* @test
*/
public function E_WARNING_errors_are_not_converted_to_exceptions()
{
Functions\expect('is_admin')->once()->andReturn(false);

$app = new Application;
$handler = Mockery::mock(HandlerInterface::class);
$app->bind(HandlerInterface::class, $handler);
$config = new Config();
$app->bind('config', $config);
$app->bind(Config::class, $config);

$handler->shouldReceive('report')->once()->with(Mockery::on(function ($e) {
return $e->getSeverity() === E_WARNING && $e->getMessage() === 'Test Error';
}));

$bootstrapper = new RegisterExceptionHandler();
$bootstrapper->bootstrap($app);
$bootstrapper->handleError(E_WARNING, 'Test Error');
}

/**
* @test
*/
Expand Down
Loading