@@ -464,18 +464,13 @@ public function test_that_it_captures_exception()
464464 $ listener ->onKernelException ($ mockEvent );
465465 }
466466
467- public function test_that_it_captures_console_exception ()
467+ /**
468+ * @dataProvider mockCommandProvider
469+ */
470+ public function test_that_it_captures_console_exception (Command $ mockCommand = null , $ expectedCommandName )
468471 {
469472 $ reportableException = new \Exception ();
470473
471- $ mockCommand = $ this ->createMock (Command::class);
472-
473- $ mockCommand
474- ->expects ($ this ->once ())
475- ->method ('getName ' )
476- ->willReturn ('cmd name ' )
477- ;
478-
479474 $ mockEvent = $ this ->createMock (ConsoleExceptionEvent::class);
480475
481476 $ mockEvent
@@ -509,7 +504,7 @@ public function test_that_it_captures_console_exception()
509504 $ this ->identicalTo ($ reportableException ),
510505 $ this ->identicalTo ([
511506 'tags ' => [
512- 'command ' => ' cmd name ' ,
507+ 'command ' => $ expectedCommandName ,
513508 'status_code ' => 10 ,
514509 ],
515510 ])
@@ -521,6 +516,21 @@ public function test_that_it_captures_console_exception()
521516 $ listener ->onConsoleException ($ mockEvent );
522517 }
523518
519+ public function mockCommandProvider ()
520+ {
521+ $ mockCommand = $ this ->createMock (Command::class);
522+ $ mockCommand
523+ ->expects ($ this ->once ())
524+ ->method ('getName ' )
525+ ->willReturn ('cmd name ' )
526+ ;
527+
528+ return [
529+ [$ mockCommand , 'cmd name ' ],
530+ [null , 'N/A ' ], // the error may have been triggered before the command is loaded
531+ ];
532+ }
533+
524534 public function test_that_it_can_replace_client ()
525535 {
526536 $ replacementClient = $ this ->createMock ('Raven_Client ' );
0 commit comments