public function testShouldMapConstructorParametersToClassProperties() { $routeArray = ['route' => '/url', 'paths' => array('module' => 'module', 'controller' => 'controller', 'action' => 'action', 'auth' => array('auth', 'authAdmin')), 'type' => 'static', 'params' => array('param_1' => 'value_1', 'param_2' => 'value_2', 'param_3' => 'value_3')]; $route = new Route('test', $routeArray); $this->assertEquals($route->getName(), 'test'); $this->assertArrayHasKey('module', $route->getPaths()); $this->assertArrayHasKey('controller', $route->getPaths()); $this->assertArrayHasKey('action', $route->getPaths()); $this->assertArrayHasKey('auth', $route->getPaths()); $this->assertEquals('value_1', $route->getParam('param_1')); $this->assertEquals('value_2', $route->getParam('param_2')); $this->assertEquals('value_3', $route->getParam('param_3')); $this->assertSame(json_encode(['auth', 'authAdmin']), $route->getPaths()['auth']); $this->assertEquals('/url', $route->getRoute()); $this->assertInternalType('array', $route->getParams()); $this->assertInternalType('string', $route->getRoute()); $this->assertInternalType('array', $route->getPaths()); $this->assertInternalType('string', $route->getName()); }
/** * {@inheritdoc} */ public function add(RouterInterface $router, Route $route) { $router->setDefaults(array_merge($route->getPaths(), ['params' => $route->getParams()])); }