tests/Routing/RouteTest.php
/**
     * Tests that parameters in the hostname (domain) function properly.
     */
Tests that parameters in the hostname (domain) function properly.
Tests that parameters in the hostname ( domain ) function properly .
public function testDomainParameters()
    {
        $this->router->createDomain('{subdomain}.test.com');
        $route = $this->router->createAnyRoute('/', function() {});
        $request1 = new Request(array(), array(), array(), array(), array(), array(
            'REQUEST_METHOD' => 'GET',
            'REQUEST_URI' => '/',
            'SERVER_NAME' => 'www.test.com'
        ));
        $request2 = new Request(array(), array(), array(), array(), array(), array(
            'REQUEST_METHOD' => 'GET',
            'REQUEST_URI' => '/',
            'SERVER_NAME' => 'test.com'
        ));
        $request1->bind($route);
        $this->assertEquals('www', $route->parameter('subdomain'));
        $request2->bind($route);
        $this->assertNull($route->parameter('subdomain'));
        $this->assertTrue($route->matches($request1));
        $this->assertFalse($route->matches($request2));
    }
public function testDomainParameters ( ) { $ this -> router -> createDomain ( '{subdomain}.test.com' ) ; $ route = $ this -> router -> createAnyRoute ( '/' , function ( ) { } ) ; $ request1 = new Request ( array ( ) , array ( ) , array ( ) , array ( ) , array ( ) , array ( 'REQUEST_METHOD' => 'GET' , 'REQUEST_URI' => '/' , 'SERVER_NAME' => 'www.test.com' ) ) ; $ request2 = new Request ( array ( ) , array ( ) , array ( ) , array ( ) , array ( ) , array ( 'REQUEST_METHOD' => 'GET' , 'REQUEST_URI' => '/' , 'SERVER_NAME' => 'test.com' ) ) ; $ request1 -> bind ( $ route ) ; $ this -> assertEquals ( 'www' , $ route -> parameter ( 'subdomain' ) ) ; $ request2 -> bind ( $ route ) ; $ this -> assertNull ( $ route -> parameter ( 'subdomain' ) ) ; $ this -> assertTrue ( $ route -> matches ( $ request1 ) ) ; $ this -> assertFalse ( $ route -> matches ( $ request2 ) ) ; }
Tests that parameters in the hostname (domain) function properly.
Tests that parameters in the hostname ( domain ) function properly .
// Set the domain globally // Create test routes // Create a request which has a subdomain // Create a request which does not have a subdomain // Test binding to non-invoking request // Test binding to invoking request // Variables in the hostname are always required