/** * @test */ public function shouldParseParameterWithSpace() { //given Route::get("/cabinets/:color/:order_id", "SummaryOrderedCorpuses#index"); $router = $this->_createRouter('GET', '/cabinets/Biały 101/18'); //when $rule = $router->findRoute(); //then $parameters = $rule->getParameters(); $this->assertEquals('Biały 101', $parameters['color']); $this->assertEquals('18', $parameters['order_id']); }
/** * @test */ public function shouldGenerateCorrectNestedResources() { //given Route::get('/api/users/:id/orders', 'api/users#orders'); //when $generated = JsUriHelperGenerator::generate()->getGeneratedFunctions(); //then $expected = <<<FUNCT function checkParameter(parameter) { if (parameter === null) { throw new Error("Uri helper: Missing parameters"); } } function ordersUsersApiPath(id) { checkParameter(id); return "/app/api/users/" + id + "/orders"; } FUNCT; $this->assertEquals($expected, $generated); }
/** * @test */ public function shouldGenerateCorrectNestedResources() { //given Route::get('/api/users/:id/orders', 'api/users#orders'); //when $generated = UriHelperGenerator::generate()->getGeneratedFunctions(); //then $expected = <<<FUNCT <?php function checkParameter(\$parameter) { if (!isset(\$parameter)) { throw new \\InvalidArgumentException("Missing parameters"); } } function ordersUsersApiPath(\$id) { checkParameter(\$id); return url("/api/users/\$id/orders"); } function allGeneratedUriNames() { return array('ordersUsersApiPath'); } FUNCT; $this->assertEquals($expected, $generated); }
<?php /* * Copyright (c) Ouzo contributors, http://ouzoframework.org * This file is made available under the MIT License (view the LICENSE file for more information). */ use Ouzo\Routing\Route; Route::get('/', 'index#index'); Route::allowAll('/users', 'users', array('except' => array('new', 'select_outbound_for_user'))); Route::get('/agents/index', 'agents#index'); Route::post('/agents/index', 'agents#index'); Route::allowAll('/photos', 'photos'); Route::any('/agents/index', 'agents#index'); Route::resource('phones'); Route::get('/agents', 'agents#index', array('as' => 'my_name')); Route::get('/agents/show/id/:id/call_id/:call_id', 'agents#show');
/** * @test */ public function shouldSaveStatsIfDebugIsOn() { //given Config::overrideProperty('debug')->with(true); Session::remove('stats_queries'); Route::get('/sample/save', 'sample#save'); //when $this->get('/sample/save'); //then $this->assertNotEmpty(Session::get('stats_queries')); }
/** * @test */ public function shouldPassUrlParametersToControllerAction() { // given Route::get('/simple_test/receive_params/:user/:page', 'simple_test#receive_params'); // when $this->get('/simple_test/receive_params/Cersei/about-us'); // then $this->assertRenderedContent()->isEqualTo('Param1: Cersei Param2: about-us'); }
<?php use Ouzo\Routing\Route; Route::get('/', 'home#index'); Route::get('/new_game', 'games#new_game'); Route::get('/end_game', 'games#end_game'); Route::get('/test', 'games#test'); Route::get('/game_content', 'games#game_content'); Route::get('/games', 'games#index'); Route::get('/games/current', 'games#game'); Route::get('/games/:id', 'games#show'); Route::post('/games', 'games#create'); Route::post('/games/new', 'games#create_new'); Route::post('/games/restart', 'games#restart'); Route::post('/games/cancel', 'games#cancel'); Route::post('/games/next_player', 'games#next_player'); Route::post('/long_poll', 'events#poll'); Route::post('/hit', 'hits#index'); Route::resource('players');
/** * @test */ public function shouldAddAllowAll() { //given Route::get('/user', 'User#index'); Route::allowAll('/user', 'User'); //when $routes = Route::getRoutes(); //then $this->assertCount(2, $routes); }