lithium\tests\cases\net\http\RouteTest::testRouteMatchingWithEmptyTrailingParams PHP Method

testRouteMatchingWithEmptyTrailingParams() public method

    public function testRouteMatchingWithEmptyTrailingParams()
    {
        $route = new Route(array('template' => '/{:controller}/{:action}/{:args}', 'modifiers' => array('args' => function ($value) {
            return explode('/', $value);
        }), 'formatters' => array('args' => function ($value) {
            return is_array($value) ? join('/', $value) : $value;
        })));
        $result = $route->match(array('controller' => 'posts'));
        $this->assertEqual('/posts', $result);
        $result = $route->match(array('controller' => 'posts', 'args' => 'foo'));
        $this->assertEqual('/posts/index/foo', $result);
        $result = $route->match(array('controller' => 'posts', 'args' => array('foo', 'bar')));
        $this->assertEqual('/posts/index/foo/bar', $result);
        $request = new Request();
        $request->url = '/posts/index/foo/bar';
        $result = $route->parse($request);
        $expected = array('controller' => 'posts', 'action' => 'index', 'args' => array('foo', 'bar'));
        $this->assertEqual($expected, $result->params);
    }