WordPress.org

Make WordPress Core

Ticket #13910: 13910.tests.patch

File 13910.tests.patch, 892 bytes (added by SpencerFinnell, 4 years ago)

Add tests for wp_nav_menu_title()

  • new file tests/phpunit/tests/nav-menus.php

    diff --git tests/phpunit/tests/nav-menus.php tests/phpunit/tests/nav-menus.php
    new file mode 100644
    index 0000000..2225ec1
    - +  
     1<?php
     2
     3/**
     4 * @group nav-menus.php
     5 */
     6class Tests_Nav_Menus extends WP_UnitTestCase {
     7
     8        /**
     9         * @ticket https://core.trac.wordpress.org/ticket/13910
     10         */
     11        function test_wp_nav_menu_title() {
     12                // Register a nav menu location.
     13                register_nav_menu( 'primary', 'Primary Navigation' );
     14
     15                // Create a menu with a title.
     16                $menu = wp_create_nav_menu( 'My Menu' );
     17
     18                // Assign the menu to the `primary` location.
     19                $locations = get_nav_menu_locations();
     20                $menu_obj = wp_get_nav_menu_object( $menu );
     21                $locations[ 'primary' ] = $menu_obj->term_id;
     22                set_theme_mod( 'nav_menu_locations', $locations );
     23
     24                $this->assertEquals( 'My Menu', wp_nav_menu_title( 'primary' ) );
     25        }
     26
     27}