Make WordPress Core

Ticket #36729: 36729.diff

File 36729.diff, 2.3 KB (added by swissspidy, 7 years ago)
  • src/wp-admin/includes/class-walker-nav-menu-edit.php

    diff --git src/wp-admin/includes/class-walker-nav-menu-edit.php src/wp-admin/includes/class-walker-nav-menu-edit.php
    index 7576de1..9a2f3ec 100644
    class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { 
    7070                        '_wpnonce',
    7171                );
    7272
    73                 $original_title = '';
     73                $original_title = false;
    7474                if ( 'taxonomy' == $item->type ) {
    7575                        $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
    7676                        if ( is_wp_error( $original_title ) )
  • new file tests/phpunit/tests/menus/walker-nav-menu-edit.php

    diff --git tests/phpunit/tests/menus/walker-nav-menu-edit.php tests/phpunit/tests/menus/walker-nav-menu-edit.php
    new file mode 100644
    index 0000000..faddac5
    - +  
     1<?php
     2
     3/**
     4 * @group navmenus
     5 * @group walker
     6 */
     7class Tests_Walker_Nav_Menu_Edit extends WP_UnitTestCase {
     8        protected $_wp_nav_menu_max_depth;
     9
     10        function setUp() {
     11                global $_wp_nav_menu_max_depth;
     12
     13                parent::setUp();
     14
     15                /** Walker_Nav_Menu_Edit class */
     16                require_once( ABSPATH . 'wp-admin/includes/class-walker-nav-menu-edit.php' );
     17
     18                $this->walker = new Walker_Nav_Menu_Edit();
     19
     20                $this->_wp_nav_menu_max_depth = $_wp_nav_menu_max_depth;
     21        }
     22
     23        function tearDown() {
     24                global $_wp_nav_menu_max_depth;
     25
     26                $_wp_nav_menu_max_depth = $this->_wp_nav_menu_max_depth;
     27
     28                parent::tearDown();
     29        }
     30
     31        /**
     32         * @group 36729
     33         */
     34        function test_original_title_prefix_should_not_be_shown_if_empty() {
     35                $expected = '';
     36
     37                $post_id = $this->factory->post->create();
     38
     39                $item = array(
     40                        'classes'          => array(),
     41                        'description'      => '',
     42                        'ID'               => $post_id,
     43                        'menu_item_parent' => 0,
     44                        'menu_order'       => 0,
     45                        'object_id'        => $post_id,
     46                        'object'           => 'post',
     47                        'post_excerpt'     => get_the_excerpt( $post_id ),
     48                        'title'            => get_the_title( $post_id ),
     49                        'type'             => 'foobar',
     50                        'type_label'       => 'Foo Bar',
     51                        'target'           => '_blank',
     52                        'url'              => '',
     53                        'xfn'              => '',
     54                );
     55
     56                $this->walker->start_el( $expected, (object) $item );
     57
     58                $this->assertNotRegExp( '#<p class="link-to-original">\s*Original: <a href=""></a>#', $expected );
     59        }
     60}