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

testParameterPersistence() public method

Tests that a request context with persistent parameters generates URLs where those parameters are properly taken into account.
    public function testParameterPersistence()
    {
        Router::connect('/{:controller}/{:action}/{:id:[0-9]+}', array(), array('persist' => array('controller', 'id')));
        // URLs generated with $request will now have the 'controller' and 'id'
        // parameters copied to new URLs.
        $request = Router::process(new Request(array('url' => 'posts/view/1138')));
        $params = array('action' => 'edit');
        $url = Router::match($params, $request);
        // Returns: '/posts/edit/1138'
        $this->assertIdentical($this->request->env('base') . '/posts/edit/1138', $url);
        Router::connect('/add/{:args}', array('controller' => 'tests', 'action' => 'add'), array('persist' => array('controller', 'action')));
        $request = Router::process(new Request(array('url' => '/add/foo/bar', 'base' => '')));
        $path = Router::match(array('args' => array('baz', 'dib')), $request);
        $this->assertIdentical('/add/baz/dib', $path);
    }
RouterTest