WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/29/2014 03:44:26 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Change the default orderby value in wp_get_nav_menus() to 'name'.

props voldemortensen, igmoweb.
fixes #29460.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/nav-menu.php

    r27556 r29792  
    117117
    118118    }
     119
     120    /**
     121     * @ticket 29460
     122     */
     123    function test_orderby_name_by_default() {
     124        // We are going to create a random number of menus (min 2, max 10)
     125        $menus_no = rand( 2, 10 );
     126
     127        for ( $i = 0; $i <= $menus_no; $i++ ) {
     128            wp_create_nav_menu( rand_str() );
     129        }
     130
     131        // This is the expected array of menu names
     132        $expected_nav_menus_names = wp_list_pluck(
     133            get_terms( 'nav_menu',  array( 'hide_empty' => false, 'orderby' => 'name' ) ),
     134            'name'
     135        );
     136
     137        // And this is what we got when calling wp_get_nav_menus()
     138        $nav_menus_names = wp_list_pluck( wp_get_nav_menus(), 'name' );
     139       
     140        $this->assertEquals( $nav_menus_names, $expected_nav_menus_names );
     141    }
    119142}
Note: See TracChangeset for help on using the changeset viewer.