Phalcon\Test\Unit\Mvc\RouterTest::testHostnameRouter PHP Method

testHostnameRouter() public method

Tests setting host name
Since: 2013-04-15
Author: Andy Gutierrez ([email protected])
public testHostnameRouter ( )
    public function testHostnameRouter()
    {
        $this->specify('The Router::getControllerName does not return correct controller by using host name', function ($hostname, $expected) {
            $router = $this->getRouter(false);
            $router->add('/edit', ['controller' => 'posts3', 'action' => 'edit3']);
            $router->add('/edit', ['controller' => 'posts', 'action' => 'edit'])->setHostname('my.phalconphp.com');
            $router->add('/edit', ['controller' => 'posts2', 'action' => 'edit2'])->setHostname('my2.phalconphp.com');
            $_SERVER['HTTP_HOST'] = $hostname;
            $router->handle('/edit');
            expect($router->getControllerName())->equals($expected);
        }, ['examples' => $this->hostnameProvider()]);
    }