lithium\tests\cases\net\http\RouterTest::testRouteMatchingWithInsertsAndDefaults PHP Method

testRouteMatchingWithInsertsAndDefaults() public method

Test matching routes with insert parameters which have default values.
    public function testRouteMatchingWithInsertsAndDefaults()
    {
        Router::connect('/{:controller}/{:action}', array('action' => 'archive'));
        $this->assertIdentical('/posts/index', Router::match(array('controller' => 'posts')));
        $result = Router::match(array('controller' => 'posts', 'action' => 'archive'));
        $this->assertIdentical('/posts', $result);
        Router::reset();
        Router::connect('/{:controller}/{:action}', array('controller' => 'users'));
        $result = Router::match(array('action' => 'view'));
        $this->assertIdentical('/users/view', $result);
        $result = Router::match(array('controller' => 'posts', 'action' => 'view'));
        $this->assertIdentical('/posts/view', $result);
        $ex = "No parameter match found for URL ";
        $ex .= "`('controller' => 'Posts', 'action' => 'view', 'id' => '2')`.";
        $this->assertException($ex, function () {
            Router::match(array('controller' => 'posts', 'action' => 'view', 'id' => '2'));
        });
    }
RouterTest