Perforce Chronicle 2012.2/486814
API Documentation

Menu_Test_WidgetControllerTest Class Reference

Test the menu widget controller. More...

List of all members.

Public Member Functions

 testDefaultMenu ()
 Test index action with default menu.
 testEmptyMenu ()
 Test the index action with empty menu.
 testGetConfigSubForm ()
 Test getting the subform.

Detailed Description

Test the menu widget controller.

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_WidgetControllerTest::testDefaultMenu ( )

Test index action with default menu.

    {
        $this->utility->impersonate('administrator');

        P4Cms_Widget::installDefaults();

        P4Cms_Menu::installDefaultMenus();

        $widget = P4Cms_Widget::factory('menu/widget');
        $widget->setValue('region', 'test')->save();

        $widget->setConfigFromArray(array('menu' => 'manage-toolbar'))->save();

        $this->dispatch('/widget/region/test/widget/' . $widget->getId());

        $this->assertModule('widget', 'Expected module.');
        $this->assertController('index', 'Expected controller');
        $this->assertAction('index', 'Expected action');

        $this->assertQuery('div.widget-menu-widget', 'Expected menu widget div');
        $this->assertXpath(
            '//div[@id="widget-' . $widget->getId() . '-content"]',
            'Expected menu widget content div'
        );
    }
Menu_Test_WidgetControllerTest::testEmptyMenu ( )

Test the index action with empty menu.

    {
        $this->utility->impersonate('administrator');

        P4Cms_Widget::installDefaults();

        $widget = P4Cms_Widget::factory('menu/widget');
        $widget->setValue('region', 'test')->save();

        $this->dispatch('/widget/region/test/widget/' . $widget->getId());
        $this->assertModule('widget', 'Expected module.');
        $this->assertController('index', 'Expected controller');
        $this->assertAction('index', 'Expected action');

        $this->assertQuery('div.widget-menu-widget', 'Expected menu widget div');
        $this->assertQueryContentContains(
            'div#widget-' . $widget->getId() . '-content',
            'No items to display.',
            'Expected no items message.'
        );
    }
Menu_Test_WidgetControllerTest::testGetConfigSubForm ( )

Test getting the subform.

    {
        $this->utility->impersonate('administrator');

        P4Cms_Widget::installDefaults();

        P4Cms_Menu::installDefaultMenus();

        $widget = P4Cms_Widget::factory('menu/widget');
        $widget->setValue('region', 'test')->save();

        $this->dispatch('/widget/index/configure/region/test/widget/' . $widget->getId());

        $this->assertModule('widget', 'Expected module.');
        $this->assertController('index', 'Expected controller');
        $this->assertAction('configure', 'Expected action');

        $this->assertXpath('//select[@name="config[menu]"]', 'Expected menu select element');
        $this->assertXpath('//select[@name="config[root]"]', 'Expected root select element');
        $this->assertXpath('//select[@name="config[maxDepth]"]', 'Expected maxDepth select element');
        $this->assertXpath('//select[@name="config[maxItems]"]', 'Expected maxItems select element');

    }

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