WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/11/2014 04:33:06 AM (6 years ago)
Author:
nacin
Message:

Ensure edit_post() promotes an auto-draft to draft. Fixes Quick Draft.

For the 3.8 branch. Regression from [27976] that does not affect trunk.

props dd32.
see #27734.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.8/tests/phpunit/tests/admin/includesPost.php

    r25002 r28073  
    55 */
    66class Tests_Admin_includesPost extends WP_UnitTestCase {
     7
     8    function tearDown() {
     9        wp_set_current_user( 0 );
     10        parent::tearDown();
     11    }
    712
    813    function test__wp_translate_postdata_cap_checks_contributor() {
     
    5762        $this->assertEquals( 'edit_others_posts', $_results->get_error_code() );
    5863        $this->assertEquals( 'You are not allowed to edit posts as this user.', $_results->get_error_message() );
    59 
    60         wp_set_current_user( 0 );
    6164    }
    6265
     
    112115        $this->assertEquals( $_post_data['post_author'], $_results['post_author'] );
    113116        $this->assertEquals( 'draft', $_results['post_status'] );
     117    }
    114118
    115         wp_set_current_user( 0 );
     119    /**
     120     * @ticket 27734
     121     */
     122    function test_edit_post_promotes_auto_draft_to_draft() {
     123        $admin = $this->factory->user->create( array( 'role' => 'administrator' ) );
     124        wp_set_current_user( $admin );
     125
     126        $post = get_default_post_to_edit( 'post', true );
     127        $post_data = array(
     128            'post_ID' => $post->ID,
     129            'post_type' => 'post',
     130            'post_content' => 'Some content',
     131        );
     132        $this->assertEquals( 'auto-draft', $post->post_status );
     133        edit_post( $post_data );
     134        $updated = get_post( $post->ID );
     135        $this->assertEquals( 'draft', $updated->post_status );
    116136    }
    117137}
Note: See TracChangeset for help on using the changeset viewer.