mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Customize: Implement customized state persistence with changesets.
Includes infrastructure developed in the Customize Snapshots feature plugin. See https://make.wordpress.org/core/2016/10/12/customize-changesets-technical-design-decisions/ Props westonruter, valendesigns, utkarshpatel, stubgo, lgedeon, ocean90, ryankienstra, mihai2u, dlh, aaroncampbell, jonathanbardo, jorbin. See #28721. See #31089. Fixes #30937. Fixes #31517. Fixes #30028. Fixes #23225. Fixes #34142. Fixes #36485. git-svn-id: https://develop.svn.wordpress.org/trunk@38810 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1240,4 +1240,50 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertEquals( 0, get_post( $page_id )->post_parent );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ensuring that the post_name (UUID) is preserved when wp_insert_post()/wp_update_post() is called.
|
||||
*
|
||||
* @see _wp_customize_changeset_filter_insert_post_data()
|
||||
* @ticket 30937
|
||||
*/
|
||||
function test_wp_insert_post_for_customize_changeset_should_not_drop_post_name() {
|
||||
|
||||
$this->assertEquals( 10, has_filter( 'wp_insert_post_data', '_wp_customize_changeset_filter_insert_post_data' ) );
|
||||
|
||||
$changeset_data = array(
|
||||
'blogname' => array(
|
||||
'value' => 'Hello World',
|
||||
),
|
||||
);
|
||||
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'contributor' ) ) );
|
||||
|
||||
$uuid = wp_generate_uuid4();
|
||||
$post_id = wp_insert_post( array(
|
||||
'post_type' => 'customize_changeset',
|
||||
'post_name' => strtoupper( $uuid ),
|
||||
'post_content' => wp_json_encode( $changeset_data ),
|
||||
) );
|
||||
$this->assertEquals( $uuid, get_post( $post_id )->post_name, 'Expected lower-case UUID4 to be inserted.' );
|
||||
$this->assertEquals( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) );
|
||||
|
||||
$changeset_data['blogname']['value'] = 'Hola Mundo';
|
||||
wp_update_post( array(
|
||||
'ID' => $post_id,
|
||||
'post_status' => 'draft',
|
||||
'post_content' => wp_json_encode( $changeset_data ),
|
||||
) );
|
||||
$this->assertEquals( $uuid, get_post( $post_id )->post_name, 'Expected post_name to not have been dropped for drafts.' );
|
||||
$this->assertEquals( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) );
|
||||
|
||||
$changeset_data['blogname']['value'] = 'Hallo Welt';
|
||||
wp_update_post( array(
|
||||
'ID' => $post_id,
|
||||
'post_status' => 'pending',
|
||||
'post_content' => wp_json_encode( $changeset_data ),
|
||||
) );
|
||||
$this->assertEquals( $uuid, get_post( $post_id )->post_name, 'Expected post_name to not have been dropped for pending.' );
|
||||
$this->assertEquals( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user