| | 29 | |
| | 30 | /** |
| | 31 | * @ticket 33742 |
| | 32 | */ |
| | 33 | public function test_search_returns_results_for_published_posts() { |
| | 34 | include_once ABSPATH . 'wp-admin/includes/nav-menu.php'; |
| | 35 | |
| | 36 | $screen = get_current_screen(); |
| | 37 | // This will make sure that WP_Query sets is_admin to true. |
| | 38 | set_current_screen( 'nav-menu.php' ); |
| | 39 | |
| | 40 | self::factory()->post->create( array( 'post_type' => 'post', 'post_status' => 'publish', 'post_title' => 'Publish', 'post_content' => 'FOO' ) ); |
| | 41 | self::factory()->post->create( array( 'post_type' => 'post', 'post_status' => 'draft', 'post_title' => 'Draft', 'post_content' => 'FOO' ) ); |
| | 42 | self::factory()->post->create( array( 'post_type' => 'post', 'post_status' => 'pending', 'post_title' => 'Pending', 'post_content' => 'FOO' ) ); |
| | 43 | self::factory()->post->create( array( 'post_type' => 'post', 'post_status' => 'future', 'post_title' => 'Future', 'post_content' => 'FOO' ) ); |
| | 44 | |
| | 45 | $request = array( |
| | 46 | 'type' => 'quick-search-posttype-post', |
| | 47 | 'q' => 'FOO', |
| | 48 | ); |
| | 49 | $output = get_echo( '_wp_ajax_menu_quick_search', array( $request ) ); |
| | 50 | |
| | 51 | $GLOBALS['current_screen'] = $screen; |
| | 52 | |
| | 53 | |
| | 54 | $this->assertNotEmpty( $output ); |
| | 55 | $results = explode( "\n", trim( $output ) ); |
| | 56 | $this->assertCount( 1, $results ); |
| | 57 | } |