WordPress.org

Make WordPress Core

Ticket #10: testpluginmenus.diff

File testpluginmenus.diff, 5.8 KB (added by duck_, 3 years ago)
  • wp-testcase/test_admin_includes_plugin.php

     
    22class TestPluginData extends WPTestCase { 
    33 
    44        function test_get_plugin_data() { 
    5                 $data = get_plugin_data(DIR_TESTDATA . '/plugins/hello.php'); 
     5                $data = get_plugin_data( DIR_TESTDATA . '/plugins/hello.php' ); 
    66 
    7                 $default_headers = array(       'Name' => 'Hello Dolly',  
    8                                                                         'Title' => '<a href="http://wordpress.org/#" title="Visit plugin homepage">Hello Dolly</a>',  
    9                                                                         'PluginURI' => 'http://wordpress.org/#',  
    10                                                                         'Description' => 'This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from Hello, Dolly in the upper right of your admin screen on every page. By <a href="http://ma.tt/" title="Visit author homepage">Matt Mullenweg</a>.', 
    11                                                                         'Author' => '<a href="http://ma.tt/" title="Visit author homepage">Matt Mullenweg</a>', 
    12                                                                         'AuthorURI' => 'http://ma.tt/', 
    13                                                                         'Version' => '1.5.1',  
    14                                                                         'TextDomain' => 'hello-dolly', 
    15                                                                         'DomainPath' => ''  
    16                                                                 );  
    17                  
    18                 $this->assertTrue(is_array($data)); 
    19                  
     7                $default_headers = array( 
     8                        'Name' => 'Hello Dolly', 
     9                        'Title' => '<a href="http://wordpress.org/#" title="Visit plugin homepage">Hello Dolly</a>', 
     10                        'PluginURI' => 'http://wordpress.org/#', 
     11                        'Description' => 'This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from Hello, Dolly in the upper right of your admin screen on every page. By <a href="http://ma.tt/" title="Visit author homepage">Matt Mullenweg</a>.', 
     12                        'Author' => '<a href="http://ma.tt/" title="Visit author homepage">Matt Mullenweg</a>', 
     13                        'AuthorURI' => 'http://ma.tt/', 
     14                        'Version' => '1.5.1', 
     15                        'TextDomain' => 'hello-dolly', 
     16                        'DomainPath' => '' 
     17                ); 
     18 
     19                $this->assertTrue( is_array($data) ); 
     20 
    2021                foreach ($default_headers as $name => $value) { 
    2122                        $this->assertTrue(isset($data[$name])); 
    2223                        $this->assertEquals($value, $data[$name]); 
     
    2627 
    2728class TestPluginMenus extends _WPEmptyBlog { 
    2829        function test_menu_page_url() { 
    29                 $this->knownWPBug(13829); 
    3030                $user = wp_get_current_user(); 
    3131                wp_set_current_user(1); 
    32                  
     32 
    3333                //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             add_pages_page('Appending Query Arg', 'Test Pages', 'edit_pages', 'testpages', 'mt_pages_page' ); 
    41              
    42             //TODO: review the http://null.host/ here and work out if this is portable enough for testing on other hosts 
    43             $expected['testsettings'] = 'http://null.host/wp-admin/options-general.php?page=testsettings'; 
    44             $expected['testtools'] = 'http://null.host/wp-admin/tools.php?page=testtools'; 
    45             $expected['mt-top-level-handle'] = 'http://null.host/wp-admin/admin.php?page=mt-top-level-handle'; 
    46             $expected['sub-page'] = 'http://null.host/wp-admin/mt-top-level-handle?page=sub-page'; 
    47             $expected['sub-page2'] = 'http://null.host/wp-admin/mt-top-level-handle?page=sub-page2'; 
    48             $expected['not_registered'] = ''; 
    49             $expected['With Spaces'] = 'http://null.host/wp-admin/themes.php?page=WithSpaces'; 
    50             $expected['testpages'] = 'http://null.host/wp-admin/edit.php?post_type=page&#038;page=testpages'; 
     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                add_pages_page( 'Appending Query Arg', 'Test Pages', 'edit_pages', 'testpages', 'mt_pages_page' ); 
    5141 
     42                $expected['testsettings'] = 'http://example.com/wp-admin/options-general.php?page=testsettings'; 
     43                $expected['testtools'] = 'http://example.com/wp-admin/tools.php?page=testtools'; 
     44                $expected['mt-top-level-handle'] = 'http://example.com/wp-admin/admin.php?page=mt-top-level-handle'; 
     45                $expected['sub-page'] = 'http://example.com/wp-admin/admin.php?page=sub-page'; 
     46                $expected['sub-page2'] = 'http://example.com/wp-admin/admin.php?page=sub-page2'; 
     47                $expected['not_registered'] = ''; 
     48                $expected['With Spaces'] = 'http://example.com/wp-admin/themes.php?page=WithSpaces'; 
     49                $expected['testpages'] = 'http://example.com/wp-admin/edit.php?post_type=page&#038;page=testpages'; 
     50 
    5251                foreach ($expected as $name => $value) { 
    53                         $this->assertEquals($value, menu_page_url($name, false) ); 
     52                        $this->assertEquals( $value, menu_page_url( $name, false ) ); 
    5453                } 
    55                  
     54 
    5655                wp_set_current_user($user->ID); 
    5756        } 
    5857} 
    59 ?> 
    60  No newline at end of file 
     58?>