Make WordPress Core


Ignore:
Timestamp:
05/16/2017 05:36:25 AM (7 years ago)
Author:
westonruter
Message:

Customize: Keep alive auto-drafts created for page/post stubs when parent changeset is updated, and delete when changeset is garbage-collected.

Props utkarshpatel, westonruter.
See #31089.
Fixes #39715.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/nav-menu.php

    r38945 r40676  
    524524        $this->assertNotContains( 'menu-item-home', $classes );
    525525    }
     526
     527    /**
     528     * Test _wp_delete_customize_changeset_dependent_auto_drafts.
     529     *
     530     * @covers _wp_delete_customize_changeset_dependent_auto_drafts()
     531     */
     532    function test_wp_delete_customize_changeset_dependent_auto_drafts() {
     533        $nav_created_post_ids = $this->factory()->post->create_many(2, array(
     534            'post_status' => 'auto-draft',
     535        ) );
     536        $data = array(
     537            'nav_menus_created_posts' => array(
     538                'value' => $nav_created_post_ids,
     539            ),
     540        );
     541        wp_set_current_user( self::factory()->user->create( array(
     542            'role' => 'administrator',
     543        ) ) );
     544        require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
     545        $wp_customize = new WP_Customize_Manager();
     546        do_action( 'customize_register', $wp_customize );
     547        $wp_customize->save_changeset_post( array(
     548            'data' => $data,
     549        ) );
     550        $this->assertInstanceOf( 'WP_Post', get_post( $nav_created_post_ids[0] ) );
     551        $this->assertInstanceOf( 'WP_Post', get_post( $nav_created_post_ids[1] ) );
     552        wp_delete_post( $wp_customize->changeset_post_id(), true );
     553        $this->assertNotInstanceOf( 'WP_Post', get_post( $nav_created_post_ids[0] ) );
     554        $this->assertNotInstanceOf( 'WP_Post', get_post( $nav_created_post_ids[1] ) );
     555    }
    526556}
Note: See TracChangeset for help on using the changeset viewer.