mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-05-29 15:44:27 +00:00
Nav Menus: Use WP_Query for quick searches.
`the_post()` sets the `$in_the_loop` property to true which is unexpected in the admin if you're using filters which should only affect real loops. Props ruud@joyo. Fixes #27042. git-svn-id: https://develop.svn.wordpress.org/trunk@37881 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
29
tests/phpunit/tests/menu/wpAjaxMenuQuickSearch.php
Normal file
29
tests/phpunit/tests/menu/wpAjaxMenuQuickSearch.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @group menu
|
||||
*/
|
||||
class Tests_Menu_WpAjaxMenuQuickSeach extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 27042
|
||||
*/
|
||||
public function test_search_returns_results_for_pages() {
|
||||
include_once ABSPATH . 'wp-admin/includes/nav-menu.php';
|
||||
|
||||
self::factory()->post->create_many( 3, array( 'post_type' => 'page', 'post_content' => 'foo' ) );
|
||||
self::factory()->post->create( array( 'post_type' => 'page', 'post_content' => 'bar' ) );
|
||||
|
||||
$request = array(
|
||||
'type' => 'quick-search-posttype-page',
|
||||
'q' => 'foo',
|
||||
'response-format' => 'json',
|
||||
);
|
||||
|
||||
$output = get_echo( '_wp_ajax_menu_quick_search', array( $request ) );
|
||||
$this->assertNotEmpty( $output );
|
||||
|
||||
$results = explode( "\n", trim( $output ) );
|
||||
$this->assertCount( 3, $results );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user