Exemplo n.º 1
0
 public function testAdvanced()
 {
     $router = new Router();
     $router->addToken('y', '[0-9]{4}');
     $router->addToken('m', '[0-9]{2}');
     $router->addToken('d', '[0-9]{2}');
     $router->add('article-with-date-and-slug', array('method' => 'GET, POST', 'route' => '(/controller)(/action(.~format))(/y-m-d(/^slug))', 'defaults' => array('controller' => 'index', 'action' => 'index', 'format' => 'html')));
     $result = $router->match('GET', '/articles/2009-01-01/some-slug-for-article');
     $expected = array('url' => array('controller' => 'articles', 'y' => '2009', 'm' => '01', 'd' => '01', 'slug' => 'some-slug-for-article'), 'id' => 'article-with-date-and-slug', 'method' => array(0 => 'GET', 1 => 'POST'), 'data' => array('controller' => 'articles', 'action' => 'index', 'format' => 'html', 'y' => '2009', 'm' => '01', 'd' => '01', 'slug' => 'some-slug-for-article'));
     $this->assertSame($expected, $result);
 }
Exemplo n.º 2
0
 /**
  * @expectedException PHPUnit_Framework_Error_Warning
  */
 public function testRepeatingTokens()
 {
     $router = new Router();
     $router->addToken('r', '[a-z]+');
     $router->add('repeating-tokens', array('method' => 'GET, POST', 'route' => '/r/r/$subreddit/comments/#thread_id/$thread_slug/'));
     $router->match('GET', '/r/r/php/comments/12/router/');
 }