@@ -363,13 +363,14 @@ public function testHandleDeprecation()
363
363
/**
364
364
* @dataProvider handleExceptionProvider
365
365
*/
366
- public function testHandleException (string $ expectedMessage , \Throwable $ exception )
366
+ public function testHandleException (string $ expectedMessage , \Throwable $ exception, string $ enhancedMessage = null )
367
367
{
368
368
try {
369
369
$ logger = $ this ->createMock (LoggerInterface::class);
370
370
$ handler = ErrorHandler::register ();
371
371
372
372
$ logArgCheck = function ($ level , $ message , $ context ) use ($ expectedMessage , $ exception ) {
373
+ $ this ->assertSame ('critical ' , $ level );
373
374
$ this ->assertSame ($ expectedMessage , $ message );
374
375
$ this ->assertArrayHasKey ('exception ' , $ context );
375
376
$ this ->assertInstanceOf ($ exception ::class, $ context ['exception ' ]);
@@ -388,11 +389,13 @@ public function testHandleException(string $expectedMessage, \Throwable $excepti
388
389
$ handler ->handleException ($ exception );
389
390
$ this ->fail ('Exception expected ' );
390
391
} catch (\Throwable $ e ) {
391
- $ this ->assertSame ($ exception , $ e );
392
+ $ this ->assertInstanceOf ($ exception ::class, $ e );
393
+ $ this ->assertSame ($ enhancedMessage ?? $ exception ->getMessage (), $ e ->getMessage ());
392
394
}
393
395
394
- $ handler ->setExceptionHandler (function ($ e ) use ($ exception ) {
395
- $ this ->assertSame ($ exception , $ e );
396
+ $ handler ->setExceptionHandler (function ($ e ) use ($ exception , $ enhancedMessage ) {
397
+ $ this ->assertInstanceOf ($ exception ::class, $ e );
398
+ $ this ->assertSame ($ enhancedMessage ?? $ exception ->getMessage (), $ e ->getMessage ());
396
399
});
397
400
398
401
$ handler ->handleException ($ exception );
@@ -412,6 +415,11 @@ public static function handleExceptionProvider(): array
412
415
})::class.' bar ' )],
413
416
['Uncaught Error: bar ' , new \Error ('bar ' )],
414
417
['Uncaught ccc ' , new \ErrorException ('ccc ' )],
418
+ [
419
+ 'Uncaught Error: Class "App\Controller\ClassDoesNotExist" not found ' ,
420
+ new \Error ('Class "App\Controller\ClassDoesNotExist" not found ' ),
421
+ "Attempted to load class \"ClassDoesNotExist \" from namespace \"App\Controller \". \nDid you forget a \"use \" statement for another namespace? " ,
422
+ ],
415
423
];
416
424
}
417
425
0 commit comments