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

testHostnameRegexRouter() public method

Tests setting host name by using regexp
Since: 2016-06-23
Author: Serghei Iakovlev ([email protected])
    public function testHostnameRegexRouter()
    {
        $this->specify('The Router::getControllerName does not return correct controller by using regexp in host name', function ($hostname, $expected) {
            $router = $this->getRouter(false);
            $router->add('/edit', ['controller' => 'posts3', 'action' => 'edit3']);
            $router->add('/edit', ['controller' => 'posts', 'action' => 'edit'])->setHostname('([a-z]+).phalconphp.com');
            $router->add('/edit', ['controller' => 'posts2', 'action' => 'edit2'])->setHostname('mail.([a-z]+).com');
            $router->add('/edit', ['controller' => 'posts4', 'action' => 'edit2'])->setHostname('([a-z]+).([a-z]+).net');
            $_SERVER['HTTP_HOST'] = $hostname;
            $router->handle('/edit');
            expect($router->getControllerName())->equals($expected);
        }, ['examples' => $this->hostnameRegexProvider()]);
    }