MethodMap::dispatch calls $next even on failure
This commit is contained in:
parent
9470f90ee2
commit
b0db3cbcdd
|
|
@ -84,7 +84,7 @@ class MethodMap implements MiddlewareInterface, MethodMapInterface
|
|||
} else {
|
||||
$response = $response->withStatus(405);
|
||||
}
|
||||
return $this->addAllowHeader($response);
|
||||
return $next($request, $this->addAllowHeader($response));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue