/** * @test */ public function shouldCreateRouteForResource() { //given GroupedRoute::resource('users'); //when $routes = Route::getRoutes(); //then Assert::thatArray($routes)->onMethod('getUri')->containsOnly('/api/users', '/api/users/fresh', '/api/users/:id/edit', '/api/users/:id', '/api/users', '/api/users/:id', '/api/users/:id', '/api/users/:id'); }
public function __construct() { $this->routeRules = $routes = Route::getRoutes(); $this->generatedFunctions .= 'function checkParameter(parameter) { ' . self::INDENT . 'if (parameter === null) { ' . self::INDENT . self::INDENT . 'throw new Error("Uri helper: Missing parameters"); ' . self::INDENT . '} }' . "\n\n"; $this->generateFunctions(); }
/** * @return UriHelperGenerator */ public static function generate() { return new self(Route::getRoutes()); }
/** * @param $path * @param $requestType * @return RouteRule */ private function findRouteRule($path, $requestType) { return Arrays::find(Route::getRoutes(), function (RouteRule $rule) use($path, $requestType) { return $rule->matches($path, $requestType); }); }
public function createController() { $routeRule = Arrays::first(Route::getRoutes()); return SampleController::createInstance($routeRule); }
private function all() { $this->_renderRoutes(Route::getRoutes()); }
/** * @test */ public function shouldAddAllowAll() { //given Route::get('/user', 'User#index'); Route::allowAll('/user', 'User'); //when $routes = Route::getRoutes(); //then $this->assertCount(2, $routes); }