Пример #1
0
 public function testGeneratingActionRoutes()
 {
     $this->routes->push($v1 = new ApiRouteCollection('v1'));
     $this->routes->push($v2 = new ApiRouteCollection('v2'));
     $v1->add(new ApiRoute(['GET'], '/api', ['controller' => 'FooController@foo']));
     $v2->add(new ApiRoute(['GET'], '/api/foo', ['controller' => 'FooController@foo']));
     $v2->add(new ApiRoute(['GET'], '/api/bar', ['controller' => 'FooController@bar']));
     $this->assertEquals('http://www.foo.com/api', $this->url->action('FooController@foo'));
     $this->assertEquals('http://www.foo.com/api/bar', $this->url->action('FooController@bar'));
 }
 /**
  * @param RouteCollection $collection
  * @return array
  */
 private function rows(RouteCollection $collection)
 {
     $rows = [];
     $routes = self::alphabetically($collection->getRoutes());
     /** @var Route $route */
     foreach ($routes as $route) {
         array_push($rows, ['method' => implode(' | ', $route->getMethods()), 'uri' => $route->uri(), 'name' => $route->getName(), 'action' => $route->getActionName(), 'middleware' => implode(' | ', $route->getMiddleware())]);
     }
     return $rows;
 }