mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-02 11:44:33 +00:00
Customize: Introduce WP_Customize_Manager::trash_changeset_post() to reduce duplication and ensure proper changeset trashing logic.
Trashing a changeset via `wp_trash_post()` does not have the desired result since it mutates `post_content` (via Kses) and the `post_name` (even though it is a UUID). Props dlh. See #39896, #42030. Fixes #42175. git-svn-id: https://develop.svn.wordpress.org/trunk@41824 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1709,6 +1709,35 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$this->assertEquals( 'expected_array', $r->get_error_code() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that trash_changeset_post() trashes a changeset post with its name and content preserved.
|
||||
*
|
||||
* @covers WP_Customize_Manager::trash_changeset_post
|
||||
*/
|
||||
public function test_trash_changeset_post_preserves_properties() {
|
||||
$args = array(
|
||||
'post_type' => 'customize_changeset',
|
||||
'post_content' => wp_json_encode( array(
|
||||
'blogname' => array(
|
||||
'value' => 'Test',
|
||||
),
|
||||
) ),
|
||||
'post_name' => wp_generate_uuid4(),
|
||||
'post_status' => 'draft',
|
||||
);
|
||||
|
||||
$post_id = wp_insert_post( $args );
|
||||
|
||||
$manager = $this->create_test_manager( $args['post_name'] );
|
||||
$manager->trash_changeset_post( $post_id );
|
||||
|
||||
$post = get_post( $post_id );
|
||||
|
||||
$this->assertSame( 'trash', get_post_status( $post_id ) );
|
||||
$this->assertSame( $args['post_name'], $post->post_name );
|
||||
$this->assertSame( $args['post_content'], $post->post_content );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register scratchpad setting.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user