Example #1
0
 public function testDelimiter()
 {
     Phalcon\Cli\Router\Route::reset();
     Phalcon\Cli\Router\Route::delimiter('/');
     $tests = array(array('uri' => '/', 'module' => 'devtools', 'task' => 'main', 'action' => 'hello', 'params' => array()), array('uri' => '/documentation/index/hellao/aaadpqñda/bbbAdld/cc-ccc', 'module' => null, 'task' => 'documentation', 'action' => 'index', 'params' => array('hellao', 'aaadpqñda', 'bbbAdld', 'cc-ccc')), array('uri' => '/documentation/index/', 'module' => null, 'task' => 'documentation', 'action' => 'index', 'params' => array()), array('uri' => '/documentation/index', 'module' => null, 'task' => 'documentation', 'action' => 'index', 'params' => array()), array('uri' => '/documentation/', 'module' => null, 'task' => 'documentation', 'action' => null, 'params' => array()), array('uri' => '/system/admin/a/edit/hellao/aaadp', 'module' => null, 'task' => 'admin', 'action' => 'edit', 'params' => array('hellao', 'aaadp')), array('uri' => '/es/news', 'module' => null, 'task' => 'news', 'action' => 'index', 'params' => array('language' => 'es')), array('uri' => '/admin/posts/edit/100', 'module' => 'admin', 'task' => 'posts', 'action' => 'edit', 'params' => array('id' => 100)), array('uri' => '/posts/2010/02/10/title/content', 'module' => null, 'task' => 'posts', 'action' => 'show', 'params' => array('year' => '2010', 'month' => '02', 'day' => '10', 0 => 'title', 1 => 'content')), array('uri' => '/manual/en/translate.adapter.txt', 'module' => null, 'task' => 'manual', 'action' => 'show', 'params' => array('language' => 'en', 'file' => 'translate.adapter')), array('uri' => '/named-manual/en/translate.adapter.txt', 'module' => null, 'task' => 'manual', 'action' => 'show', 'params' => array('language' => 'en', 'file' => 'translate.adapter')), array('uri' => '/posts/1999/s/le-nice-title', 'module' => null, 'task' => 'posts', 'action' => 'show', 'params' => array('year' => '1999', 'title' => 'le-nice-title')), array('uri' => '/feed/fr/blog/diaporema.json', 'module' => null, 'task' => 'feed', 'action' => 'get', 'params' => array('lang' => 'fr', 'blog' => 'diaporema', 'type' => 'json')), array('uri' => '/posts/delete/150', 'module' => null, 'task' => 'posts', 'action' => 'delete', 'params' => array('id' => '150')), array('uri' => '/very/static/route', 'module' => null, 'task' => 'static', 'action' => 'route', 'params' => array()));
     $router = new \Phalcon\CLI\Router();
     $router->add('/', array('module' => 'devtools', 'task' => 'main', 'action' => 'hello'));
     $router->add('/system/:task/a/:action/:params', array('task' => 1, 'action' => 2, 'params' => 3));
     $router->add('/([a-z]{2})/:task', array('task' => 2, 'action' => 'index', 'language' => 1));
     $router->add('/admin/:task/:action/:int', array('module' => 'admin', 'task' => 1, 'action' => 2, 'id' => 3));
     $router->add('/posts/([0-9]{4})/([0-9]{2})/([0-9]{2})/:params', array('task' => 'posts', 'action' => 'show', 'year' => 1, 'month' => 2, 'day' => 3, 'params' => 4));
     $router->add('/manual/([a-z]{2})/([a-z\\.]+)\\.txt', array('task' => 'manual', 'action' => 'show', 'language' => 1, 'file' => 2));
     $router->add('/named-manual/{language:([a-z]{2})}/{file:[a-z\\.]+}\\.txt', array('task' => 'manual', 'action' => 'show'));
     $router->add('/very/static/route', array('task' => '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");
     foreach ($tests as $n => $test) {
         $this->_runTest($router, $test);
     }
 }