WordPress.org

Make WordPress Core

Changeset 49112


Ignore:
Timestamp:
10/09/2020 01:27:50 PM (5 months ago)
Author:
SergeyBiryukov
Message:

Tests: Use consistent wording for the $position parameter in add_submenu_page() tests.

This replaces the instances of $priority with $position, to match the actual parameter name and avoid confusion.

Follow-up to [46197].

See #51344, #39776.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/admin/includesPlugin.php

    r48937 r49112  
    5959
    6060    /**
    61      * Tests the priority parameter.
     61     * Tests the position parameter.
    6262     *
    6363     * @ticket 39776
     
    6565     * @covers ::add_submenu_page
    6666     *
    67      * @param int $priority          The position of the new item.
     67     * @param int $position          The position passed for the new item.
    6868     * @param int $expected_position Where the new item is expected to appear.
    6969     *
    70      * @dataProvider data_submenu_priority
    71      */
    72     function test_submenu_priority( $priority, $expected_position ) {
     70     * @dataProvider data_submenu_position
     71     */
     72    function test_submenu_position( $position, $expected_position ) {
    7373        global $submenu;
    7474        global $menu;
     
    8585
    8686        // Insert the new page.
    87         add_submenu_page( $parent, 'New Page', 'New Page', 'manage_options', 'custom-position', 'custom_pos', $priority );
     87        add_submenu_page( $parent, 'New Page', 'New Page', 'manage_options', 'custom-position', 'custom_pos', $position );
    8888        wp_set_current_user( $current_user );
    8989
     
    9696
    9797    /**
    98      * Tests the priority parameter for menu helper functions.
     98     * Tests the position parameter for menu helper functions.
    9999     *
    100100     * @ticket 39776
     
    113113     * @covers ::add_comments_page
    114114     *
    115      * @param int $priority          The position of the new item.
     115     * @param int $position          The position passed for the new item.
    116116     * @param int $expected_position Where the new item is expected to appear.
    117117     *
    118      * @dataProvider data_submenu_priority
    119      */
    120     function test_submenu_helpers_priority( $priority, $expected_position ) {
     118     * @dataProvider data_submenu_position
     119     */
     120    function test_submenu_helpers_position( $position, $expected_position ) {
    121121        global $submenu;
    122122        global $menu;
     
    190190            $test = 'test_' . $helper_function['callback'];
    191191
    192             // Call the helper function, passing the desired priority.
    193             call_user_func_array( $helper_function['callback'], array( $test, $test, 'manage_options', 'custom-position', '', $priority ) );
     192            // Call the helper function, passing the desired position.
     193            call_user_func_array( $helper_function['callback'], array( $test, $test, 'manage_options', 'custom-position', '', $position ) );
    194194
    195195            $actual_positions[ $test ] = $submenu[ $helper_function['menu_root'] ][ $expected_position ][2];
     
    222222    function submenus_to_add() {
    223223        return array(
    224             array( 'Submenu Priority', 'Submenu Priority', 'manage_options', 'sub-page', '' ),
    225             array( 'Submenu Priority 2', 'Submenu Priority 2', 'manage_options', 'sub-page2', '' ),
    226             array( 'Submenu Priority 3', 'Submenu Priority 3', 'manage_options', 'sub-page3', '' ),
    227             array( 'Submenu Priority 4', 'Submenu Priority 4', 'manage_options', 'sub-page4', '' ),
    228             array( 'Submenu Priority 5', 'Submenu Priority 5', 'manage_options', 'sub-page5', '' ),
     224            array( 'Submenu Position', 'Submenu Position', 'manage_options', 'sub-page', '' ),
     225            array( 'Submenu Position 2', 'Submenu Position 2', 'manage_options', 'sub-page2', '' ),
     226            array( 'Submenu Position 3', 'Submenu Position 3', 'manage_options', 'sub-page3', '' ),
     227            array( 'Submenu Position 4', 'Submenu Position 4', 'manage_options', 'sub-page4', '' ),
     228            array( 'Submenu Position 5', 'Submenu Position 5', 'manage_options', 'sub-page5', '' ),
    229229        );
    230230    }
    231231
    232232    /**
    233      * Data provider for test_submenu_helpers_priority().
     233     * Data provider for test_submenu_helpers_position().
    234234     *
    235235     * @since 5.3.0
     
    237237     * @return array {
    238238     *     @type array {
    239      *         @type int|null Priority.
     239     *         @type int|null Passed position.
    240240     *         @type int      Expected position.
    241241     *     }
    242242     * }
    243243     */
    244     function data_submenu_priority() {
     244    function data_submenu_position() {
    245245        $menu_count = count( $this->submenus_to_add() );
    246246        return array(
     
    257257
    258258    /**
    259      * Test that when a submenu has the same slug as a parent item, that it's just appended and ignores the priority.
     259     * Test that when a submenu has the same slug as a parent item, that it's just appended and ignores the position.
    260260     *
    261261     * @ticket 48599
    262262     */
    263     function test_priority_when_parent_slug_child_slug_are_the_same() {
     263    function test_position_when_parent_slug_child_slug_are_the_same() {
    264264        global $submenu, $menu;
    265265
     
    289289
    290290    /**
    291      * Passing a string as priority will fail.
     291     * Passing a string as position will fail.
    292292     *
    293293     * @ticket 48599
    294294     */
    295     function test_passing_string_as_priority_fires_doing_it_wrong() {
     295    function test_passing_string_as_position_fires_doing_it_wrong() {
    296296        $this->setExpectedIncorrectUsage( 'add_submenu_page' );
    297297        global $submenu, $menu;
Note: See TracChangeset for help on using the changeset viewer.