/** * @test */ public function shouldGenerateUriHelperForPost() { //given Route::post('/users/save', 'users#save'); //when $generated = UriHelperGenerator::generate()->getGeneratedFunctions(); //then $expected = <<<FUNCT <?php function checkParameter(\$parameter) { if (!isset(\$parameter)) { throw new \\InvalidArgumentException("Missing parameters"); } } function saveUsersPath() { return url("/users/save"); } function allGeneratedUriNames() { return array('saveUsersPath'); } FUNCT; $this->assertEquals($expected, $generated); }
/** * @test */ public function shouldGenerateUriHelperForPost() { //given Route::post('/users/save', 'users#save'); //when $generated = JsUriHelperGenerator::generate()->getGeneratedFunctions(); //then $expected = <<<FUNCT function checkParameter(parameter) { if (parameter === null) { throw new Error("Uri helper: Missing parameters"); } } function saveUsersPath() { return "/app/users/save"; } FUNCT; $this->assertEquals($expected, $generated); }
/** * @test */ public function shouldFindRouteRuleUtf8() { //given Route::post('/api/agents/:login/free', 'api/agents#free'); $router = $this->_createRouter('POST', '/api/agents/userπ/free'); //when $rule = $router->findRoute(); //then $this->assertEquals('/api/agents/:login/free', $rule->getUri()); $this->assertEquals('POST', $rule->getMethod()); $this->assertEquals('api/agents', $rule->getController()); $this->assertEquals('free', $rule->getAction()); }
<?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 shouldRemoveDuplicatedPrefixFromUrlWhenExists() { //given Route::post('/sample/redirect_to', 'sample#redirect_to'); //when $this->post('/sample/redirect_to', array()); //then $this->assertRedirectsTo('/sample/add'); }
/** * @test */ public function shouldPassOnlyUrlParametersNotPostOrGet() { // given Route::post('/simple_test2/receive_params/:user', 'simple_test#receive_params'); // when CatchException::when($this)->post('/simple_test2/receive_params/Cersei', array('page' => 'about-us')); // then $this->assertRenderedContent()->isEqualTo(null); CatchException::assertThat()->hasMessage('Missing argument 2 for SimpleTestController::receive_params()'); }
<?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 shouldSetRuleNameForMultipartCamelcaseAction() { //given Route::post('/users/save', 'users#saveMyUser'); //when $routes = Route::getRoutes(); //then $this->assertEquals('saveMyUserUsersPath', $routes[0]->getName()); }