MethodMap::dispatch calls $next even on failure

This commit is contained in:
PJ Dietz 2015-05-09 20:20:17 -04:00
parent 9470f90ee2
commit b0db3cbcdd
2 changed files with 20 additions and 1 deletions

View File

@ -84,7 +84,7 @@ class MethodMap implements MiddlewareInterface, MethodMapInterface
} else { } else {
$response = $response->withStatus(405); $response = $response->withStatus(405);
} }
return $this->addAllowHeader($response); return $next($request, $this->addAllowHeader($response));
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------

View File

@ -197,6 +197,25 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase
$this->response->withStatus(405)->shouldHaveBeenCalled(); $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 ::dispatch
* @covers ::addAllowHeader * @covers ::addAllowHeader