12
12
namespace Symfony \Component \Debug \Tests ;
13
13
14
14
use PHPUnit \Framework \TestCase ;
15
+ use Psr \Log \LoggerInterface ;
15
16
use Psr \Log \LogLevel ;
16
17
use Psr \Log \NullLogger ;
17
18
use Symfony \Component \Debug \BufferingLogger ;
18
19
use Symfony \Component \Debug \ErrorHandler ;
20
+ use Symfony \Component \Debug \Exception \ClassNotFoundException ;
19
21
use Symfony \Component \Debug \Exception \SilencedErrorContext ;
20
22
use Symfony \Component \Debug \Tests \Fixtures \ErrorHandlerThatUsesThePreviousOne ;
21
23
use Symfony \Component \Debug \Tests \Fixtures \LoggerThatSetAnErrorHandler ;
@@ -72,7 +74,7 @@ public function testRegister()
72
74
73
75
public function testErrorGetLast ()
74
76
{
75
- $ logger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
77
+ $ logger = $ this ->createMock ( LoggerInterface::class);
76
78
$ handler = ErrorHandler::register ();
77
79
$ handler ->setDefaultLogger ($ logger );
78
80
$ handler ->screamAt (\E_ALL );
@@ -150,7 +152,7 @@ public function testConstruct()
150
152
public function testDefaultLogger ()
151
153
{
152
154
try {
153
- $ logger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
155
+ $ logger = $ this ->createMock ( LoggerInterface::class);
154
156
$ handler = ErrorHandler::register ();
155
157
156
158
$ handler ->setDefaultLogger ($ logger , \E_NOTICE );
@@ -225,7 +227,7 @@ public function testHandleError()
225
227
restore_error_handler ();
226
228
restore_exception_handler ();
227
229
228
- $ logger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
230
+ $ logger = $ this ->createMock ( LoggerInterface::class);
229
231
230
232
$ warnArgCheck = function ($ logLevel , $ message , $ context ) {
231
233
$ this ->assertEquals ('info ' , $ logLevel );
@@ -250,7 +252,7 @@ public function testHandleError()
250
252
restore_error_handler ();
251
253
restore_exception_handler ();
252
254
253
- $ logger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
255
+ $ logger = $ this ->createMock ( LoggerInterface::class);
254
256
255
257
$ line = null ;
256
258
$ logArgCheck = function ($ level , $ message , $ context ) use (&$ line ) {
@@ -355,7 +357,7 @@ public function testHandleDeprecation()
355
357
$ this ->assertSame ('User Deprecated: Foo deprecation ' , $ exception ->getMessage ());
356
358
};
357
359
358
- $ logger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
360
+ $ logger = $ this ->createMock ( LoggerInterface::class);
359
361
$ logger
360
362
->expects ($ this ->once ())
361
363
->method ('log ' )
@@ -370,7 +372,7 @@ public function testHandleDeprecation()
370
372
public function testHandleException ()
371
373
{
372
374
try {
373
- $ logger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
375
+ $ logger = $ this ->createMock ( LoggerInterface::class);
374
376
$ handler = ErrorHandler::register ();
375
377
376
378
$ exception = new \Exception ('foo ' );
@@ -450,7 +452,7 @@ public function testBootstrappingLogger()
450
452
451
453
$ bootLogger ->log (LogLevel::WARNING , 'Foo message ' , ['exception ' => $ exception ]);
452
454
453
- $ mockLogger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
455
+ $ mockLogger = $ this ->createMock ( LoggerInterface::class);
454
456
$ mockLogger ->expects ($ this ->once ())
455
457
->method ('log ' )
456
458
->with (LogLevel::WARNING , 'Foo message ' , ['exception ' => $ exception ]);
@@ -465,7 +467,7 @@ public function testSettingLoggerWhenExceptionIsBuffered()
465
467
466
468
$ exception = new \Exception ('Foo message ' );
467
469
468
- $ mockLogger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
470
+ $ mockLogger = $ this ->createMock ( LoggerInterface::class);
469
471
$ mockLogger ->expects ($ this ->once ())
470
472
->method ('log ' )
471
473
->with (LogLevel::CRITICAL , 'Uncaught Exception: Foo message ' , ['exception ' => $ exception ]);
@@ -480,7 +482,7 @@ public function testSettingLoggerWhenExceptionIsBuffered()
480
482
public function testHandleFatalError ()
481
483
{
482
484
try {
483
- $ logger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
485
+ $ logger = $ this ->createMock ( LoggerInterface::class);
484
486
$ handler = ErrorHandler::register ();
485
487
486
488
$ error = [
@@ -527,7 +529,7 @@ public function testHandleErrorException()
527
529
528
530
$ handler ->handleException ($ exception );
529
531
530
- $ this ->assertInstanceOf (\ Symfony \ Component \ Debug \ Exception \ ClassNotFoundException::class, $ args [0 ]);
532
+ $ this ->assertInstanceOf (ClassNotFoundException::class, $ args [0 ]);
531
533
$ this ->assertStringStartsWith ("Attempted to load class \"IReallyReallyDoNotExistAnywhereInTheRepositoryISwear \" from the global namespace. \nDid you forget a \"use \" statement " , $ args [0 ]->getMessage ());
532
534
}
533
535
0 commit comments