/** * Routes the request the handler most appropriate. * * @return void */ protected function routeRequest() { $match = $this->router->match($this->api->resources, $this->request->getMethod(), $this->request->getPathInfo()); switch ($match->status) { case Router::FOUND: $this->routeToHandlers($match); break; case Router::NOT_FOUND: $this->routeToNotFound(); break; case Router::METHOD_NOT_ALLOWED: $this->routeToNotAllowed($match); break; } }
function testMethodNotAllowedMatch() { $this->cache->get("router")->shouldBeCalled()->willReturn(TestResource::expectedTable()); $router = new Router($this->cache->reveal(), new UrlTools()); $resources = array(__NAMESPACE__ . "\\TestResource"); $match = $router->match($resources, "POST", "/this/is/static"); $this->assertEquals(Router::METHOD_NOT_ALLOWED, $match->status, "Match"); $this->assertEquals(array("GET"), $match->allowed, "Allowed"); }