WordPress.org

Make WordPress Core

Ticket #45361: 45361.5.diff

File 45361.5.diff, 1.4 KB (added by welcher, 6 months ago)

Adds unit tests

  • src/wp-includes/nav-menu.php

    diff --git src/wp-includes/nav-menu.php src/wp-includes/nav-menu.php
    index f130d2f3e1..ba1d777bbb 100644
    function register_nav_menus( $locations = array() ) { 
    9292
    9393        add_theme_support( 'menus' );
    9494
     95        foreach ( $locations as $key => $value ) {
     96                if ( is_int( $key ) ) {
     97                        $message = __( 'Strings should always be used for menu location slugs.' );
     98                        _doing_it_wrong( __FUNCTION__, $message, '5.3' );
     99                        break;
     100                }
     101        }
     102
    95103        $_wp_registered_nav_menus = array_merge( (array) $_wp_registered_nav_menus, $locations );
    96104}
    97105
  • tests/phpunit/tests/menu/nav-menu.php

    diff --git tests/phpunit/tests/menu/nav-menu.php tests/phpunit/tests/menu/nav-menu.php
    index 2627f9f21a..4577f5e9a9 100644
    class Tests_Nav_Menu_Theme_Change extends WP_UnitTestCase { 
    182182        /**
    183183         * Technically possible to register menu locations numerically.
    184184         *
     185         * @expectedIncorrectUsage register_nav_menus
     186         *
    185187         * @covers ::wp_map_nav_menu_locations()
    186188         */
    187189        function test_numerical_locations() {
    class Tests_Nav_Menu_Theme_Change extends WP_UnitTestCase { 
    205207        /**
    206208         * Technically possible old nav menu locations were registered numerically.
    207209         *
     210         * @expectedIncorrectUsage register_nav_menus
     211         *
    208212         * @covers wp_map_nav_menu_locations()
    209213         */
    210214        public function test_numerical_old_locations() {