any() public static method

public static any ( $uri, $action, array $options = [] )
$options array
    /**
     * @test
     */
    public function shouldGenerateUriHelperForAny()
    {
        //given
        Route::any('/users/get_duplicated', 'users#get_duplicated');
        //when
        $generated = UriHelperGenerator::generate()->getGeneratedFunctions();
        //then
        $expected = <<<FUNCT
<?php
function checkParameter(\$parameter)
{
    if (!isset(\$parameter)) {
        throw new \\InvalidArgumentException("Missing parameters");
    }
}

function getDuplicatedUsersPath()
{
    return url("/users/get_duplicated");
}

function allGeneratedUriNames()
{
    return array('getDuplicatedUsersPath');
}
FUNCT;
        $this->assertEquals($expected, $generated);
    }
    /**
     * @test
     */
    public function shouldGenerateUriHelperForAny()
    {
        //given
        Route::any('/users/get_duplicated', 'users#get_duplicated');
        //when
        $generated = JsUriHelperGenerator::generate()->getGeneratedFunctions();
        //then
        $expected = <<<FUNCT
function checkParameter(parameter) {
    if (parameter === null) {
        throw new Error("Uri helper: Missing parameters");
    }
}

function getDuplicatedUsersPath() {
    return "/app/users/get_duplicated";
}

FUNCT;
        $this->assertEquals($expected, $generated);
    }
Beispiel #3
0
 /**
  * @test
  * @dataProvider requestMethods
  * @param string $method
  */
 public function shouldFindRouteAny($method)
 {
     //given
     Route::any('/user/save', 'User#save');
     $router = $this->_createRouter($method, '/user/save');
     //when
     $rule = $router->findRoute();
     //then
     $this->assertEquals('/user/save', $rule->getUri());
     $this->assertContains($method, $rule->getMethod());
     $this->assertEquals('User', $rule->getController());
     $this->assertEquals('save', $rule->getAction());
 }
Beispiel #4
0
 /**
  * @test
  */
 public function shouldInvokeFunctionCallback()
 {
     //given
     SampleController::$beforeActionResult = true;
     SampleController::$beforeCallback = function ($controller) {
         $controller->redirect('url');
         return true;
     };
     Route::any('/sample/action', 'sample#action');
     //when
     $this->get('/sample/action');
     //then
     $this->assertRedirectsTo('url');
 }
Beispiel #5
0
<?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');
Beispiel #6
0
 /**
  * @test
  */
 public function shouldSetCustomRuleNameToAnyMethod()
 {
     //given
     Route::any('/users/add', 'users#add', array('as' => 'create_user'));
     //when
     $routes = Route::getRoutes();
     //then
     $this->assertEquals('createUserPath', $routes[0]->getName());
 }