tests/Routing/RouteTest.php
/**
     * Tests that optional route parameter values inherit default values when not set.
     */
Tests that optional route parameter values inherit default values when not set.
Tests that optional route parameter values inherit default values when not set .
public function testBindingDefaults()
    {
        $route = $this->router->createAnyRoute('/{var}/{optional?}', function() {
        })->defaults('optional', 'default');
        $request1 = new Request(array(), array(), array(), array(), array(), array(
            'REQUEST_METHOD' => 'GET',
            'REQUEST_URI' => '/test'
        ));
        $request2 = new Request(array(), array(), array(), array(), array(), array(
            'REQUEST_METHOD' => 'GET',
            'REQUEST_URI' => '/test/overwrite'
        ));
        $request1->bind($route);
        $this->assertEquals('test', $route->parameter('var'));
        $this->assertEquals('default', $route->parameter('optional'));
        $request2->bind($route);
        $this->assertEquals('test', $route->parameter('var'));
        $this->assertEquals('overwrite', $route->parameter('optional'));
    }
public function testBindingDefaults ( ) { $ route = $ this -> router -> createAnyRoute ( '/{var}/{optional?}' , function ( ) { } ) -> defaults ( 'optional' , 'default' ) ; $ request1 = new Request ( array ( ) , array ( ) , array ( ) , array ( ) , array ( ) , array ( 'REQUEST_METHOD' => 'GET' , 'REQUEST_URI' => '/test' ) ) ; $ request2 = new Request ( array ( ) , array ( ) , array ( ) , array ( ) , array ( ) , array ( 'REQUEST_METHOD' => 'GET' , 'REQUEST_URI' => '/test/overwrite' ) ) ; $ request1 -> bind ( $ route ) ; $ this -> assertEquals ( 'test' , $ route -> parameter ( 'var' ) ) ; $ this -> assertEquals ( 'default' , $ route -> parameter ( 'optional' ) ) ; $ request2 -> bind ( $ route ) ; $ this -> assertEquals ( 'test' , $ route -> parameter ( 'var' ) ) ; $ this -> assertEquals ( 'overwrite' , $ route -> parameter ( 'optional' ) ) ; }
Tests that optional route parameter values inherit default values when not set.
Tests that optional route parameter values inherit default values when not set .
// Create a route with an optional variable that has a default // Create a request which does not invoke the optional variable // Create a request which does invoke the optional variable // Test binding to non-invoking request // Test binding to invoking request