@@ -112,6 +112,10 @@ public function testTerminate()
112112 {
113113 $ app = new Application ();
114114
115+ $ app ->get ('/ ' , function (ServerRequestInterface $ request , ResponseInterface $ response , array $ args = []) {
116+ return $ response ;
117+ });
118+
115119 $ app ->addListener ('response.sent ' , function (HttpApplicationEvent $ event ) {
116120 $ this ->assertInstanceOf ('League\Event\Event ' , $ event );
117121 $ this ->assertInstanceOf (ServerRequestInterface::class, $ event ->getRequest ());
@@ -205,6 +209,7 @@ public function testHandleAutoWiringControllerAction()
205209 */
206210 public function testHandleWithOtherException ()
207211 {
212+
208213 $ app = new Application ();
209214
210215 $ request = ServerRequestFactory::fromGlobals ();
@@ -225,12 +230,11 @@ public function testHandleWithOtherException()
225230 }
226231
227232 /**
228- *
233+ * This should not throw errors
229234 */
230- public function testExceptionHandling ()
235+ public function testHttpErrorHandling ()
231236 {
232237 $ app = new Application ();
233- $ app ->setConfig ('error ' , false );
234238
235239 $ request = ServerRequestFactory::fromGlobals ();
236240
@@ -404,7 +408,7 @@ public function testApplicationMiddlewareOnError()
404408 {
405409 $ app = new Application ();
406410 $ handledOnError = false ;
407- $ app ->addMiddleware (function (ServerRequestInterface $ request , ResponseInterface $ response , callable $ next ) use (&$ handledOnError ){
411+ $ app ->addMiddleware (function (ServerRequestInterface $ request , ResponseInterface $ response , callable $ next ) use (&$ handledOnError ) {
408412 $ handledOnError = true ;
409413 return $ response ;
410414 });
@@ -420,7 +424,7 @@ public function testApplicationMiddleware()
420424 $ app = new Application ();
421425 $ handled = false ;
422426 $ app ->get ('/ ' , [TestController::class, 'getIndex ' ]);
423- $ app ->addMiddleware (function (ServerRequestInterface $ request , ResponseInterface $ response , callable $ next ) use (&$ handled ){
427+ $ app ->addMiddleware (function (ServerRequestInterface $ request , ResponseInterface $ response , callable $ next ) use (&$ handled ) {
424428 $ handled = true ;
425429 $ response ->getBody ()->write ('< ' );
426430 /** @var ResponseInterface $response */
@@ -439,13 +443,12 @@ public function testApplicationMiddleware()
439443 public function testErrorHandler ()
440444 {
441445 $ app = new Application ();
442- $ response = $ app ->handle (ServerRequestFactory::fromGlobals ());
443446
444- $ text = $ response ->getBody ()->__toString ();
447+ $ response = $ app ->handle (ServerRequestFactory::fromGlobals ());
448+ $ app ->shutdown ($ response );
445449
446450 $ this ->assertTrue ($ app ->isError ());
447- $ this ->assertEquals ('League\Route\Http\Exception\NotFoundException ' , substr ($ text , 0 , strpos ($ text , ': ' )));
448- $ this ->assertInstanceOf ('League\Route\Http\Exception\NotFoundException ' , $ app ->getLastException ());
451+ $ this ->assertInstanceOf ('\League\Route\Http\Exception\NotFoundException ' , $ app ->getLastException ());
449452 }
450453
451454
0 commit comments