WordPress.org

Make WordPress Core

Changeset 308 in tests


Ignore:
Timestamp:
06/10/10 21:34:50 (4 years ago)
Author:
westi
Message:

Add some test cases for menu_page_url. See WP#13829 for more info.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_admin_includes_plugin.php

    r247 r308  
    2424    } 
    2525} 
     26 
     27class TestPluginMenus extends _WPEmptyBlog { 
     28    function test_menu_page_url() { 
     29        $this->knownWPBug(13829); 
     30        $user = wp_get_current_user(); 
     31        wp_set_current_user(1); 
     32         
     33        //Add some pages 
     34        add_options_page('Test Settings', 'Test Settings', 'manage_options', 'testsettings', 'mt_settings_page'); 
     35        add_management_page('Test Tools', 'Test Tools', 'manage_options', 'testtools', 'mt_tools_page'); 
     36        add_menu_page('Test Toplevel', 'Test Toplevel', 'manage_options', 'mt-top-level-handle', 'mt_toplevel_page' ); 
     37        add_submenu_page('mt-top-level-handle', 'Test Sublevel', 'Test Sublevel', 'manage_options', 'sub-page', 'mt_sublevel_page'); 
     38        add_submenu_page('mt-top-level-handle', 'Test Sublevel 2', 'Test Sublevel 2', 'manage_options', 'sub-page2', 'mt_sublevel_page2'); 
     39        add_theme_page('With Spaces', 'With Spaces', 'manage_options', 'With Spaces', 'mt_tools_page'); 
     40         
     41        //TODO: review the http://null.host/ here and work out if this is portable enough for testing on other hosts 
     42        $expected['testsettings'] = 'http://null.host/wp-admin/options-general.php?page=testsettings'; 
     43        $expected['testtools'] = 'http://null.host/wp-admin/tools.php?page=testtools'; 
     44        $expected['mt-top-level-handle'] = 'http://null.host/wp-admin/admin.php?page=mt-top-level-handle'; 
     45        $expected['sub-page'] = 'http://null.host/wp-admin/mt-top-level-handle?page=sub-page'; 
     46        $expected['sub-page2'] = 'http://null.host/wp-admin/mt-top-level-handle?page=sub-page2'; 
     47        $expected['not_registered'] = ''; 
     48        $expected['With Spaces'] = 'http://null.host/wp-admin/themes.php?page=WithSpaces'; 
     49         
     50        foreach ($expected as $name => $value) { 
     51            $this->assertEquals($value, menu_page_url($name, false) ); 
     52        } 
     53         
     54        wp_set_current_user($user->ID); 
     55    } 
     56} 
    2657?> 
Note: See TracChangeset for help on using the changeset viewer.