Perforce Chronicle 2012.2/486814
API Documentation

Menu_Test_MenuItemMvcFormTest Class Reference

Test the MVC menu item form. More...

List of all members.

Public Member Functions

 testGetValues ()
 Test handling when params are all strings.
 testSetDefaultsParamsArray ()
 Test handling when params is an array instead of a config string.
 testSetDefaultsRouteSplit ()
 Test handling when route is split into its parts instead of a single action string.

Detailed Description

Test the MVC menu item form.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

Menu_Test_MenuItemMvcFormTest::testGetValues ( )

Test handling when params are all strings.

    {
        $form = new Menu_Form_MenuItemMvc();
        
        $module     = 'menu';
        $controller = 'index';
        $action     = 'index';
        
        $defaults = array(
            'menuId'    => 'testmenu',
            'id'        => 'testitem',
            'uuid'      => 'testitem',
            'label'     => 'testItem',
            'position'  => 'under',
            'location'  => 'testmenu',
            'type'      => 'P4Cms_Navigation_Page_Mvc',
            'action'    => $module . '/' . $controller . '/' . $action,
            'params'    => 'format=json'
        );
        
        $formatArray = array('format' => 'json');
        
        $form->setDefaults($defaults);
        $values = $form->getValues();
        
        $this->assertEquals($values['module'], $module);
        $this->assertEquals($values['controller'], $controller);
        $this->assertEquals($values['action'], $action);
        $this->assertEquals($values['params'], $formatArray);
        $this->assertEquals($values['label'], $defaults['label']);
    }
Menu_Test_MenuItemMvcFormTest::testSetDefaultsParamsArray ( )

Test handling when params is an array instead of a config string.

    {
        $form = new Menu_Form_MenuItemMvc();
        
        $defaults = array(
            'menuId'    => 'testmenu',
            'id'        => 'testitem',
            'uuid'      => 'testitem',
            'label'     => 'testItem',
            'position'  => 'under',
            'location'  => 'testmenu',
            'type'      => 'P4Cms_Navigation_Page_Mvc',
            'action'    => 'menu/index/index',
            'params'    => array(
                'format'    => 'json'
            )
        );
        
        $form->setDefaults($defaults);
        $params = $form->getValue('params');
        
        $this->assertTrue(is_string($params));
    }
Menu_Test_MenuItemMvcFormTest::testSetDefaultsRouteSplit ( )

Test handling when route is split into its parts instead of a single action string.

    {
        $form = new Menu_Form_MenuItemMvc();
        
        $module     = 'menu';
        $controller = 'index';
        $action     = 'index';
        
        $defaults = array(
            'menuId'    => 'testmenu',
            'id'        => 'testitem',
            'uuid'      => 'testitem',
            'label'     => 'testItem',
            'position'  => 'under',
            'location'  => 'testmenu',
            'type'      => 'P4Cms_Navigation_Page_Mvc',
            'module'    => $module,
            'controller'=> $controller,
            'action'    => $action,
            'params'    => array(
                'format'    => 'json'
            )
        );
        
        $form->setDefaults($defaults);
        $value = $form->getValue('action');
        
        $this->assertEquals($value, $module . '/' . $controller . '/' . $action);
    }

The documentation for this class was generated from the following file: