Make WordPress Core


Ignore:
Timestamp:
05/02/2020 10:34:50 PM (5 years ago)
Author:
johnbillion
Message:

Menus: Allow empty taxonomy terms to be surfaced when searching for items.

This brings the behaviour inline with that of browsing terms or using the All Items tab, which correctly shows empty terms.

Props birgire, audrasjb

Fixes #45298

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/menu/wpAjaxMenuQuickSearch.php

    r47200 r47747  
    121121        $this->assertCount( 1, $results );
    122122    }
     123
     124    /**
     125     * Test that search displays terms that are not assigned to any posts.
     126     *
     127     * @ticket 45298
     128     */
     129    public function test_search_should_return_unassigned_term_items() {
     130        register_taxonomy( 'wptests_tax', 'post' );
     131
     132        $this->factory->term->create(
     133            array(
     134                'taxonomy' => 'wptests_tax',
     135                'name'     => 'foobar',
     136            )
     137        );
     138
     139        $request = array(
     140            'type' => 'quick-search-taxonomy-wptests_tax',
     141            'q'    => 'foobar',
     142        );
     143        $output  = get_echo( '_wp_ajax_menu_quick_search', array( $request ) );
     144
     145        $this->assertNotEmpty( $output );
     146        $results = explode( "\n", trim( $output ) );
     147        $this->assertCount( 1, $results );
     148    }
    123149}
Note: See TracChangeset for help on using the changeset viewer.