Commit c6efc8d6 authored by Chris Graham's avatar Chris Graham
Browse files

Fixed MANTIS-4432 (Add testing for menu URL handling)

parent a0551b34
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ class menu_test_set extends cms_test_case
    {
        parent::setUp();

        require_code('menus');
        require_code('menus2');

        $this->menu_id = add_menu_item('Test', 1, null, 'testing menu', 'http://www.example.com', 1, 'downloads', 0, 1, 'testing');
@@ -38,6 +39,41 @@ class menu_test_set extends cms_test_case
        $this->assertTrue('Service' == $GLOBALS['SITE_DB']->query_select_value('menu_items', 'i_menu', array('id' => $this->menu_id)));
    }

    public function testURLRendering()
    {
        $urls = array();

        $branch = array(
            'title' => 'test',
            'content_type' => 'stored_branch',
            'content_id' => null,
            'modifiers' => array(),
            'only_on_page' => '',
            'extra_meta' => array(
            ),
            'has_possible_children' => false,
            'children' => array(),
        );

        $tests = array();
        $tests[] = array(
            'url' => static_evaluate_tempcode(build_url(array('page' => 'rules'), '')),
            'page_link' => '',
        );
        $tests[] = array(
            'url' => '',
            'page_link' => ':rules',
        );

        foreach ($tests as $test) {
            $result = _render_menu_branch($branch + $test, 'test', db_get_first_id(), 0, 'tree', false, array($branch), false);

            $url = $result[0]['URL']->evaluate();
            $urls[] = $url;
            $this->assertTrue($url == $urls[0], $url . ' vs ' . $urls[0]);
        }
    }

    public function tearDown()
    {
        delete_menu_item($this->menu_id);