lithium\tests\cases\action\DispatcherTest::testRunWithSpecialRuleAsCallable PHP Method

testRunWithSpecialRuleAsCallable() public method

    public function testRunWithSpecialRuleAsCallable()
    {
        MockDispatcher::config(array('rules' => function ($params) {
            if (isset($params['admin'])) {
                return array('special' => array('action' => 'special_{:action}'));
            }
            return array();
        }));
        Router::connect('/', array('controller' => 'test', 'action' => 'test', 'admin' => true));
        Router::connect('/special', array('controller' => 'test', 'action' => 'test', 'admin' => true, 'special' => true));
        MockDispatcher::run(new Request(array('url' => '/')));
        $result = end(MockDispatcher::$dispatched);
        $expected = array('action' => 'test', 'controller' => 'Test', 'admin' => true);
        $this->assertEqual($expected, $result->params);
        MockDispatcher::run(new Request(array('url' => '/special')));
        $result = end(MockDispatcher::$dispatched);
        $expected = array('action' => 'special_test', 'controller' => 'Test', 'admin' => true, 'special' => true);
        $this->assertEqual($expected, $result->params);
    }