Make WordPress Core


Ignore:
Timestamp:
11/04/2016 07:23:49 AM (7 years ago)
Author:
westonruter
Message:

Customize: Ensure page/post stubs are included in listings and searches for available nav menu items.

Include the customized state in the Ajax requests to load items and search items.

See #38573.
Fixes #38122.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ajax/CustomizeMenus.php

    r39137 r39138  
    323323     */
    324324    function test2_ajax_load_available_items_structure( $post_args ) {
     325        do_action( 'customize_register', $this->wp_customize );
    325326
    326327        $expected_keys = array(
     
    337338        self::factory()->term->create_many( 5 );
    338339        self::factory()->post->create_many( 5, array( 'post_type' => 'page' ) );
     340        $auto_draft_post = $this->wp_customize->nav_menus->insert_auto_draft_post( array( 'post_title' => 'Test Auto Draft', 'post_type' => 'post' ) );
     341        $this->wp_customize->set_post_value( 'nav_menus_created_posts', array( $auto_draft_post->ID ) );
     342        $this->wp_customize->get_setting( 'nav_menus_created_posts' )->preview();
    339343
    340344        $_POST = array_merge( array(
     
    372376                }
    373377            }
     378        } elseif ( 'post' === $test_item['object'] ) {
     379            $item_ids = wp_list_pluck( $response['data']['items']['post_type:post'], 'id' );
     380            $this->assertContains( 'post-' . $auto_draft_post->ID, $item_ids );
    374381        }
    375382    }
     
    498505     */
    499506    function test_ajax_search_available_items_results( $post_args, $expected_results ) {
     507        do_action( 'customize_register', $this->wp_customize );
    500508
    501509        self::factory()->post->create_many( 5, array( 'post_title' => 'Test Post' ) );
     510        $included_auto_draft_post = $this->wp_customize->nav_menus->insert_auto_draft_post( array( 'post_title' => 'Test Included Auto Draft', 'post_type' => 'post' ) );
     511        $excluded_auto_draft_post = $this->wp_customize->nav_menus->insert_auto_draft_post( array( 'post_title' => 'Excluded Auto Draft', 'post_type' => 'post' ) );
     512        $this->wp_customize->set_post_value( 'nav_menus_created_posts', array( $included_auto_draft_post->ID, $excluded_auto_draft_post->ID ) );
     513        $this->wp_customize->get_setting( 'nav_menus_created_posts' )->preview();
    502514
    503515        $_POST = array_merge( array(
     
    512524        if ( isset( $post_args['search'] ) && 'test' === $post_args['search'] ) {
    513525            $this->assertsame( true, $response['success'] );
    514             $this->assertSame( 5, count( $response['data']['items'] ) );
     526            $this->assertSame( 6, count( $response['data']['items'] ) );
     527            $item_ids = wp_list_pluck( $response['data']['items'], 'id' );
     528            $this->assertContains( 'post-' . $included_auto_draft_post->ID, $item_ids );
     529            $this->assertNotContains( 'post-' . $excluded_auto_draft_post->ID, $item_ids );
    515530        } else {
    516531            $this->assertSame( $expected_results, $response );
    517532        }
    518 
    519533    }
    520534
Note: See TracChangeset for help on using the changeset viewer.