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

testMatchingWithTheRouter() public method

Tests router
Since: 2013-01-17
Author: Andy Gutierrez ([email protected])
    public function testMatchingWithTheRouter()
    {
        $this->specify('Router does not matched correctly', function ($uri, $controller, $action, $params) {
            $router = $this->getRouter();
            $router->add('/', ['controller' => 'index', 'action' => 'index']);
            $router->add('/system/:controller/a/:action/:params', ['controller' => 1, 'action' => 2, 'params' => 3]);
            $router->add('/([a-z]{2})/:controller', ['controller' => 2, 'action' => 'index', 'language' => 1]);
            $router->add('/admin/:controller/:action/:int', ['controller' => 1, 'action' => 2, 'id' => 3]);
            $router->add('/posts/([0-9]{4})/([0-9]{2})/([0-9]{2})/:params', ['controller' => 'posts', 'action' => 'show', 'year' => 1, 'month' => 2, 'day' => 3, 'params' => 4]);
            $router->add('/manual/([a-z]{2})/([a-z\\.]+)\\.html', ['controller' => 'manual', 'action' => 'show', 'language' => 1, 'file' => 2]);
            $router->add('/named-manual/{language:([a-z]{2})}/{file:[a-z\\.]+}\\.html', ['controller' => 'manual', 'action' => 'show']);
            $router->add('/very/static/route', ['controller' => 'static', 'action' => 'route']);
            $router->add('/feed/{lang:[a-z]+}/blog/{blog:[a-z\\-]+}\\.{type:[a-z\\-]+}', 'Feed::get');
            $router->add('/posts/{year:[0-9]+}/s/{title:[a-z\\-]+}', 'Posts::show');
            $router->add('/posts/delete/{id}', 'Posts::delete');
            $router->add('/show/{id:video([0-9]+)}/{title:[a-z\\-]+}', 'Videos::show');
            $router->handle($uri);
            expect($router->getControllerName())->equals($controller);
            expect($router->getActionName())->equals($action);
            expect($router->getParams())->equals($params);
        }, ['examples' => $this->routerProvider()]);
    }