/** * @test */ public function shouldExceptActionInAllAllow() { //given Route::allowAll('/sample', 'sample', array('except' => array('except'))); //when try { $this->get('/sample/except'); $this->fail(); } catch (RouterException $e) { //then $this->assertEquals('No route rule found for HTTP method [GET] and URI [/sample/except]', $e->getMessage()); } }
/** * @test */ public function shouldNotDisplayOutputBeforeHeadersAreSent() { //given $self = $this; $obLevel = ob_get_level(); Mock::when($this->frontController->getHeaderSender())->send(Mock::any())->thenAnswer(function () use($self, $obLevel) { //if there's a nested buffer, nothing was sent to output $self->assertTrue(ob_get_level() > $obLevel); $self->expectOutputString('OUTPUT'); }); Route::allowAll('/sample', 'sample'); //when $this->get('/sample/action'); //then no exceptions }
/** * @test */ public function shouldFindRouteWhenDeclaredAnIsInExcept() { //given Route::get('/users/add', 'users#add'); Route::allowAll('/users', 'users', array('except' => array('add'))); $router = $this->_createRouter('GET', '/users/add'); //when $rule = $router->findRoute(); //then $this->assertNotEmpty($rule); $this->assertEquals('GET', $rule->getMethod()); $this->assertEquals('add', $rule->getAction()); $this->assertEquals('users', $rule->getController()); }
public function setUp() { parent::setUp(); Route::$validate = false; Route::allowAll('/auth_sample', 'auth_sample'); }
/** * @test */ public function shouldNotGenerateCorrectAllowAllResource() { //given Route::allowAll('/api', 'api'); //when $generated = JsUriHelperGenerator::generate()->getGeneratedFunctions(); //then $expected = <<<FUNCT function checkParameter(parameter) { if (parameter === null) { throw new Error("Uri helper: Missing parameters"); } } 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 shouldGetStringOutput() { //given Route::allowAll('/simple_test', 'simple_test'); //when $this->get('/simple_test/string_output'); //then $this->assertEquals('ONLY OUTPUT', $this->getActualContent()); }
/** * @test */ public function shouldAddAllowAll() { //given Route::get('/user', 'User#index'); Route::allowAll('/user', 'User'); //when $routes = Route::getRoutes(); //then $this->assertCount(2, $routes); }