Always convert auto-drafts to drafts in edit_draft() and _wp_translate_postdata().

This regressed due to refactoring in [26995]. This commit fixes Quick Draft.

see #25272.


git-svn-id: https://develop.svn.wordpress.org/trunk@27405 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2014-03-05 06:25:31 +00:00
parent 83b61e9400
commit a14b999605
2 changed files with 27 additions and 3 deletions
@@ -114,4 +114,26 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
wp_set_current_user( 0 );
}
/**
* edit_post() should convert an existing auto-draft to a draft.
*
* @ticket 25272
*/
function test_edit_post_auto_draft() {
$user_id = $this->factory->user->create( array( 'role' => 'editor' ) );
wp_set_current_user( $user_id );
$post = $this->factory->post->create_and_get( array( 'post_status' => 'auto-draft' ) );
$this->assertEquals( 'auto-draft', $post->post_status );
$post_data = array(
'post_title' => 'Post title',
'content' => 'Post content',
'post_type' => 'post',
'post_ID' => $post->ID,
);
edit_post( $post_data );
$this->assertEquals( 'draft', get_post( $post->ID )->post_status );
wp_set_current_user( 0 );
}
}