Пример #1
0
 public function testCreateFromConfigurationFactory()
 {
     $configuration = ['route' => '/example', 'namespace' => 'Example\\Namespace', 'controller' => 'RouteController', 'action' => 'testAction'];
     $route = Route::createFromRouteConfiguration($configuration);
     $this->assertInstanceOf('\\Alien\\Routing\\RouteInterface', $route);
     $this->assertEquals('/example', $route->getRoute());
     $this->assertEquals('Example\\Namespace\\RouteController', $route->getControllerClass());
     $this->assertEquals('testAction', $route->getAction());
     $this->assertEquals([], $route->getParams());
 }
Пример #2
0
 /**
  * Returns route configuration by it's name
  *
  * <b>NOTE</b>: This method is able to find match only at top level of tree (simple routes only).
  *
  * @param string $name
  * @return RouteInterface
  * @throws RouteNotFoundException when route is not found
  */
 public function getRoute($name)
 {
     if (array_key_exists($name, $this->routes)) {
         return Route::createFromRouteConfiguration($this->routes[$name]);
     } else {
         throw new RouteNotFoundException("Route not found");
     }
 }