function it_throws_method_not_allowed(RouteInterface $route, UrlMatcherInterface $matcher) { $route->getPattern()->willReturn('/foo'); $route->getMethod()->willReturn('POST'); $route->getHandler()->willReturn('bar'); $this->addRoute($route); $request = Request::create('/foo', 'GET'); $matcher->match('/foo', '/foo')->willReturn([]); $ex = new MethodNotAllowedException('GET', '/foo', ['POST']); $this->shouldThrow($ex)->duringRun($request); }
public function addRoute(RouteInterface $route) { $pattern = $route->getPattern(); $method = $route->getMethod(); $handler = $route->getHandler(); $this->handlers[$pattern] = $handler; if (!isset($this->methods[$handler])) { $this->methods[$handler] = []; } $this->methods[$handler][] = $method; return $this; }