public function testMethods() { $route = new Route('name', 'sourceRoute', 'action'); $this->assertEquals($route->getMethods(), ['GET']); $route->setMethods(['POST']); $this->assertEquals($route->getMethods(), ['POST']); $route->addMethod('HEAD'); $this->assertEquals($route->getMethods(), ['POST', 'HEAD']); $route->removeMethod('POST'); $this->assertEquals($route->getMethods(), ['HEAD']); $this->assertEquals($route->isSatisfiedByMethod('HEAD'), true); $this->assertEquals($route->isSatisfiedByMethod('GET'), false); $route->addMethod('GET'); $this->assertEquals($route->isSatisfiedByMethod('GET'), true); }
/** * Transforms Route object to PHP array. * @param Route $route Route object to transform. * @return array */ public function transformRouteToArray(Route $route) { return ['name' => $route->getName(), 'action' => $route->getAction(), 'rules' => $route->getRules(), 'methods' => $route->getMethods(), 'route' => $route->getRoute(), 'sourceRoute' => $route->getSourceRoute(), 'defaults' => $route->getDefaults(), 'extras' => $route->getExtras(), 'tokens' => $route->getTokens(), 'arguments' => $route->getArguments()]; }