From b0db3cbcddb15f759f15a8346b63cee9b212857c Mon Sep 17 00:00:00 2001 From: PJ Dietz Date: Sat, 9 May 2015 20:20:17 -0400 Subject: [PATCH] MethodMap::dispatch calls $next even on failure --- src/Routing/MethodMap.php | 2 +- test/tests/unit/Routing/MethodMapTest.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Routing/MethodMap.php b/src/Routing/MethodMap.php index 960f8c4..bb5309b 100644 --- a/src/Routing/MethodMap.php +++ b/src/Routing/MethodMap.php @@ -84,7 +84,7 @@ class MethodMap implements MiddlewareInterface, MethodMapInterface } else { $response = $response->withStatus(405); } - return $this->addAllowHeader($response); + return $next($request, $this->addAllowHeader($response)); } // ------------------------------------------------------------------------ diff --git a/test/tests/unit/Routing/MethodMapTest.php b/test/tests/unit/Routing/MethodMapTest.php index df2f1a3..39efe67 100644 --- a/test/tests/unit/Routing/MethodMapTest.php +++ b/test/tests/unit/Routing/MethodMapTest.php @@ -197,6 +197,25 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase $this->response->withStatus(405)->shouldHaveBeenCalled(); } + /** + * @coversNothing + * @dataProvider allowedMethodProvider + */ + public function testCallsNextForBadMethod() + { + $calledNext = false; + $next = function ($request, $response) use (&$calledNext) { + $calledNext = true; + return $response; + }; + $this->request->getMethod()->willReturn("POST"); + + $map = new MethodMap(); + $map->register("GET", $this->middleware->reveal()); + $map->dispatch($this->request->reveal(), $this->response->reveal(), $next); + $this->assertTrue($calledNext); + } + /** * @covers ::dispatch * @covers ::addAllowHeader