function testMethods() { $route = new Route('/path', ''); $this->assertEquals([], $route->getMethods()); $route->setMethods(['get']); $this->assertEquals(['get'], $route->getMethods()); }
function testMethodNotAllowedException() { $routes = new RouteCollection(); $route = new Route('/foo/{id}/bar/{name}', ''); $route->setMethods(['POST', 'PUT']); $routes->add($route); $context = RequestContext::create(); $this->assertEquals(['post', 'put'], $route->getMethods()); $this->assertEquals('GET', $context->getMethod()); $matcher = new Matcher($context); $this->setExpectedExceptionRegExp('Slince\\Routing\\Exception\\MethodNotAllowedException'); $matcher->match('/foo/100/bar/steven', $routes); }