mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-11 08:04:32 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@40676 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -309,4 +309,36 @@ class Tests_Theme extends WP_UnitTestCase {
|
||||
$this->assertEquals($template, get_template());
|
||||
$this->assertEquals($style, get_stylesheet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test _wp_keep_alive_customize_changeset_dependent_auto_drafts.
|
||||
*
|
||||
* @covers _wp_keep_alive_customize_changeset_dependent_auto_drafts()
|
||||
*/
|
||||
function test_wp_keep_alive_customize_changeset_dependent_auto_drafts() {
|
||||
$nav_created_post_ids = $this->factory()->post->create_many(2, array(
|
||||
'post_status' => 'auto-draft',
|
||||
) );
|
||||
$data = array(
|
||||
'nav_menus_created_posts' => array(
|
||||
'value' => $nav_created_post_ids,
|
||||
),
|
||||
);
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
|
||||
$wp_customize = new WP_Customize_Manager();
|
||||
do_action( 'customize_register', $wp_customize );
|
||||
$wp_customize->save_changeset_post( array(
|
||||
'data' => $data,
|
||||
) );
|
||||
$this->assertEquals( get_post( $nav_created_post_ids[0] )->post_date, get_post( $wp_customize->changeset_post_id() )->post_date );
|
||||
$this->assertEquals( get_post( $nav_created_post_ids[1] )->post_date, get_post( $wp_customize->changeset_post_id() )->post_date );
|
||||
$wp_customize->save_changeset_post( array(
|
||||
'status' => 'draft',
|
||||
'data' => $data,
|
||||
) );
|
||||
$expected_year = date( 'Y' ) + 100;
|
||||
$this->assertEquals( $expected_year, date( 'Y', strtotime( get_post( $nav_created_post_ids[0] )->post_date ) ) );
|
||||
$this->assertEquals( $expected_year, date( 'Y', strtotime( get_post( $nav_created_post_ids[1] )->post_date ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user