Perforce Chronicle 2012.2/486814
API Documentation

Ui_Test_DijitMenuTest Class Reference

Test methods for the P4Cms DijitMenu Navigation View Helper. More...

List of all members.

Public Member Functions

 testRenderFlatMenu ()
 Verify flat menu gets properly output.
 testRenderNestedMenu ()
 Verify nested menu gets properly output.

Detailed Description

Test methods for the P4Cms DijitMenu Navigation View Helper.

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

Ui_Test_DijitMenuTest::testRenderFlatMenu ( )

Verify flat menu gets properly output.

    {
        $view   = Zend_Layout::getMvcInstance()->getView();
        $helper = $view->navigation()->findHelper('dijitMenu');

        $output = $helper->renderMenu(
            new P4Cms_Navigation(
                array(
                    array(
                        'label'     => 'Test',
                        'uri'       => 'http://example.com',
                        'class'     => 'blahIcon',
                        'onShow'    => 'console.log("show");',
                    ),
                    array(
                        'label'     => '-'
                    ),
                    array(
                        'label'     => '--'
                    ),
                    array(
                        'label'     => 'Test2',
                        'uri'       => '',
                        'onClick'   => 'alert("hello!");',
                        'class'     => 'blahIcon',
                        'onShow'    => 'console.log("show");'
                    )
                )
            ),
            array(
                'attribs' => array(
                    'id'  => 'test',
                    'style' => 'display:none;'
                )
            )
        );

        $expected = '<div dojoType="p4cms.ui.Menu" id="dijitmenu-test" style="display:none;"'
                  . ' wrapperClass=" level-0">' . "\n"
                  . '        <div dojotype="dijit.MenuItem" iconClass="blahIcon">'
                  . '<script type="dojo/connect" event="onClick">window.location = "http:\/\/example.com"'
                  . '</script><script type="dojo/connect" event="onShow" args="menuItem,menu">'
                  . 'console.log("show");</script>Test</div>' . "\n"
                  . '        <div dojotype="dijit.MenuSeparator"></div>' . "\n"
                  . '        <div dojotype="dijit.MenuSeparator"></div>' . "\n"
                  . '        <div dojotype="dijit.MenuItem" iconClass="blahIcon">'
                  . '<script type="dojo/connect" event="onClick">alert("hello!");</script>'
                  . '<script type="dojo/connect" event="onShow" args="menuItem,menu">'
                  . 'console.log("show");</script>Test2</div>' . "\n"
                  . '</div>';

        $this->assertSame($expected, $output, 'Expected matching output.');
    }
Ui_Test_DijitMenuTest::testRenderNestedMenu ( )

Verify nested menu gets properly output.

    {
        $view   = Zend_Layout::getMvcInstance()->getView();
        $helper = $view->navigation()->findHelper('dijitMenu');

        $output = $helper->renderMenu(
            new P4Cms_Navigation(
                array(
                    array(
                        'label'     => 'Test',
                        'uri'       => 'http://example.com',
                        'class'     => 'blahIcon',
                        'onShow'    => 'console.log("show");',
                        'pages'     => array(
                            array(
                                'label'     => 'Test2',
                                'uri'       => '',
                                'onClick'   => 'alert("hello!");',
                                'class'     => 'blahIcon',
                                'onShow'    => 'console.log("show");'
                            )
                        )
                    )
                )
            ),
            array(
                'attribs' => array(
                    'id'  => 'test',
                    'style' => 'display:none;'
                )
            )
        );

        $expected = '<div dojoType="p4cms.ui.Menu" id="dijitmenu-test" style="display:none;"'
                  . ' wrapperClass=" level-0">' . "\n"
                  . '        <div dojotype="dijit.PopupMenuItem"><span>Test</span>' . "\n"
                  . '        <div dojoType="p4cms.ui.Menu" wrapperClass=" level-1">' . "\n"
                  . '                <div dojotype="dijit.MenuItem" iconClass="blahIcon">'
                  . '<script type="dojo/connect" event="onClick">alert("hello!");</script>'
                  . '<script type="dojo/connect" event="onShow" args="menuItem,menu">'
                  . 'console.log("show");</script>Test2</div>' . "\n"
                  . '        </div>' . "\n"
                  . '        </div>' . "\n"
                  . '</div>';

        $this->assertSame($expected, $output, 'Expected matching output.');
    }

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