1212namespace Symfony \Component \Debug \Tests ;
1313
1414use PHPUnit \Framework \TestCase ;
15+ use Psr \Log \LoggerInterface ;
1516use Psr \Log \LogLevel ;
1617use Psr \Log \NullLogger ;
1718use Symfony \Component \Debug \BufferingLogger ;
1819use Symfony \Component \Debug \ErrorHandler ;
20+ use Symfony \Component \Debug \Exception \ClassNotFoundException ;
1921use Symfony \Component \Debug \Exception \SilencedErrorContext ;
2022use Symfony \Component \Debug \Tests \Fixtures \ErrorHandlerThatUsesThePreviousOne ;
2123use Symfony \Component \Debug \Tests \Fixtures \LoggerThatSetAnErrorHandler ;
@@ -72,7 +74,7 @@ public function testRegister()
7274
7375 public function testErrorGetLast ()
7476 {
75- $ logger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
77+ $ logger = $ this ->createMock ( LoggerInterface::class);
7678 $ handler = ErrorHandler::register ();
7779 $ handler ->setDefaultLogger ($ logger );
7880 $ handler ->screamAt (\E_ALL );
@@ -150,7 +152,7 @@ public function testConstruct()
150152 public function testDefaultLogger ()
151153 {
152154 try {
153- $ logger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
155+ $ logger = $ this ->createMock ( LoggerInterface::class);
154156 $ handler = ErrorHandler::register ();
155157
156158 $ handler ->setDefaultLogger ($ logger , \E_NOTICE );
@@ -225,7 +227,7 @@ public function testHandleError()
225227 restore_error_handler ();
226228 restore_exception_handler ();
227229
228- $ logger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
230+ $ logger = $ this ->createMock ( LoggerInterface::class);
229231
230232 $ warnArgCheck = function ($ logLevel , $ message , $ context ) {
231233 $ this ->assertEquals ('info ' , $ logLevel );
@@ -250,7 +252,7 @@ public function testHandleError()
250252 restore_error_handler ();
251253 restore_exception_handler ();
252254
253- $ logger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
255+ $ logger = $ this ->createMock ( LoggerInterface::class);
254256
255257 $ line = null ;
256258 $ logArgCheck = function ($ level , $ message , $ context ) use (&$ line ) {
@@ -355,7 +357,7 @@ public function testHandleDeprecation()
355357 $ this ->assertSame ('User Deprecated: Foo deprecation ' , $ exception ->getMessage ());
356358 };
357359
358- $ logger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
360+ $ logger = $ this ->createMock ( LoggerInterface::class);
359361 $ logger
360362 ->expects ($ this ->once ())
361363 ->method ('log ' )
@@ -370,7 +372,7 @@ public function testHandleDeprecation()
370372 public function testHandleException ()
371373 {
372374 try {
373- $ logger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
375+ $ logger = $ this ->createMock ( LoggerInterface::class);
374376 $ handler = ErrorHandler::register ();
375377
376378 $ exception = new \Exception ('foo ' );
@@ -450,7 +452,7 @@ public function testBootstrappingLogger()
450452
451453 $ bootLogger ->log (LogLevel::WARNING , 'Foo message ' , ['exception ' => $ exception ]);
452454
453- $ mockLogger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
455+ $ mockLogger = $ this ->createMock ( LoggerInterface::class);
454456 $ mockLogger ->expects ($ this ->once ())
455457 ->method ('log ' )
456458 ->with (LogLevel::WARNING , 'Foo message ' , ['exception ' => $ exception ]);
@@ -465,7 +467,7 @@ public function testSettingLoggerWhenExceptionIsBuffered()
465467
466468 $ exception = new \Exception ('Foo message ' );
467469
468- $ mockLogger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
470+ $ mockLogger = $ this ->createMock ( LoggerInterface::class);
469471 $ mockLogger ->expects ($ this ->once ())
470472 ->method ('log ' )
471473 ->with (LogLevel::CRITICAL , 'Uncaught Exception: Foo message ' , ['exception ' => $ exception ]);
@@ -480,7 +482,7 @@ public function testSettingLoggerWhenExceptionIsBuffered()
480482 public function testHandleFatalError ()
481483 {
482484 try {
483- $ logger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
485+ $ logger = $ this ->createMock ( LoggerInterface::class);
484486 $ handler = ErrorHandler::register ();
485487
486488 $ error = [
@@ -527,7 +529,7 @@ public function testHandleErrorException()
527529
528530 $ handler ->handleException ($ exception );
529531
530- $ this ->assertInstanceOf (\ Symfony \ Component \ Debug \ Exception \ ClassNotFoundException::class, $ args [0 ]);
532+ $ this ->assertInstanceOf (ClassNotFoundException::class, $ args [0 ]);
531533 $ this ->assertStringStartsWith ("Attempted to load class \"IReallyReallyDoNotExistAnywhereInTheRepositoryISwear \" from the global namespace. \nDid you forget a \"use \" statement " , $ args [0 ]->getMessage ());
532534 }
533535
0 commit comments