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