@@ -914,7 +914,7 @@ public function testRunWithDispatcher()
914
914
}
915
915
916
916
/**
917
- * @expectedException \LogicException
917
+ * @expectedException \RuntimeException
918
918
* @expectedExceptionMessage caught
919
919
*/
920
920
public function testRunWithExceptionAndDispatcher ()
@@ -925,7 +925,7 @@ public function testRunWithExceptionAndDispatcher()
925
925
$ application ->setCatchExceptions (false );
926
926
927
927
$ application ->register ('foo ' )->setCode (function (InputInterface $ input , OutputInterface $ output ) {
928
- throw new \RuntimeException ('foo ' );
928
+ throw new \RuntimeException ('caught ' );
929
929
});
930
930
931
931
$ tester = new ApplicationTester ($ application );
@@ -949,37 +949,42 @@ public function testRunDispatchesAllEventsWithException()
949
949
$ this ->assertContains ('before.foo.caught.after. ' , $ tester ->getDisplay ());
950
950
}
951
951
952
- public function testRunDispatchesAllEventsWithError ()
952
+ /**
953
+ * @expectedException \Error
954
+ * @expectedExceptionMessage caught
955
+ */
956
+ public function testRunWithErrorAndDispatcher ()
953
957
{
954
958
$ application = new Application ();
955
959
$ application ->setDispatcher ($ this ->getDispatcher ());
956
960
$ application ->setAutoExit (false );
961
+ $ application ->setCatchExceptions (false );
957
962
958
- $ application ->register ('dym ' )->setCode (function (InputInterface $ input , OutputInterface $ output ) {
959
- $ output ->write ('dym. ' );
960
-
961
- throw new \Error ('dymerr ' );
963
+ $ application ->register ('foo ' )->setCode (function (InputInterface $ input , OutputInterface $ output ) {
964
+ throw new \Error ('caught ' );
962
965
});
963
966
964
967
$ tester = new ApplicationTester ($ application );
965
- $ tester ->run (array ('command ' => 'dym ' ));
966
- $ this ->assertContains ('before.dym.caught.after. ' , $ tester ->getDisplay (), 'The PHP Error did not dispached events ' );
968
+ $ tester ->run (array ('command ' => 'foo ' ));
967
969
}
968
970
971
+ /**
972
+ * @expectedException \Error
973
+ * @expectedExceptionMessage caught
974
+ */
969
975
public function testRunWithErrorFailingStatusCode ()
970
976
{
971
977
$ application = new Application ();
972
978
$ application ->setDispatcher ($ this ->getDispatcher ());
973
979
$ application ->setAutoExit (false );
980
+ $ application ->setCatchExceptions (false );
974
981
975
- $ application ->register ('dus ' )->setCode (function (InputInterface $ input , OutputInterface $ output ) {
976
- $ output ->write ('dus. ' );
977
-
978
- throw new \Error ('duserr ' );
982
+ $ application ->register ('foo ' )->setCode (function (InputInterface $ input , OutputInterface $ output ) {
983
+ throw new \Error ('caught ' );
979
984
});
980
985
981
986
$ tester = new ApplicationTester ($ application );
982
- $ tester ->run (array ('command ' => 'dus ' ));
987
+ $ tester ->run (array ('command ' => 'foo ' ));
983
988
$ this ->assertSame (1 , $ tester ->getStatusCode (), 'Status code should be 1 ' );
984
989
}
985
990
0 commit comments