WordPress.org

Make WordPress Core

Changeset 37044


Ignore:
Timestamp:
03/22/2016 03:11:06 PM (6 years ago)
Author:
rachelbaker
Message:

XMLRPC: Unit tests left off [r37043]

See #35874.

Props redsweater, rachelbaker

Location:
trunk/tests/phpunit/tests/xmlrpc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/xmlrpc/mw/editPost.php

    r36163 r37044  
    242242        $this->assertEmpty( $tags2 );
    243243    }
     244
     245    /**
     246     * @ticket 35874
     247     */
     248    function test_draft_not_prematurely_published() {
     249        $editor_id = $this->make_user_by_role( 'editor' );
     250
     251        $post = array(
     252            'title' => 'Title',
     253        );
     254
     255        /**
     256         * We have to use wp_newPost method, rather than the factory
     257         * post->create method to create the database conditions that exhibit
     258         * the bug.
     259         */
     260        $post_id = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) );
     261
     262        // Change the post's status to publish and date to future.
     263        $future_time = strtotime( '+1 day' );
     264        $future_date = new IXR_Date( $future_time );
     265        $this->myxmlrpcserver->mw_editPost( array(
     266            $post_id,
     267            'editor',
     268            'editor',
     269            array(
     270                'dateCreated' => $future_date,
     271                'post_status' => 'publish',
     272            ),
     273        ) );
     274
     275        $after = get_post( $post_id );
     276        $this->assertEquals( 'future', $after->post_status );
     277
     278        $future_date_string = strftime( '%Y-%m-%d %H:%M:%S', $future_time );
     279        $this->assertEquals( $future_date_string, $after->post_date );
     280    }
    244281}
  • trunk/tests/phpunit/tests/xmlrpc/wp/editPost.php

    r35242 r37044  
    402402        $this->assertTrue( in_array( $enclosure_string, get_post_meta( $post_id, 'enclosure' ) ) );
    403403    }
     404
     405    /**
     406     * @ticket 35874
     407     */
     408    function test_draft_not_prematurely_published() {
     409        $editor_id = $this->make_user_by_role( 'editor' );
     410
     411        /**
     412         * We have to use wp_newPost method, rather than the factory
     413         * post->create method to create the database conditions that exhibit
     414         * the bug.
     415         */
     416        $post = array(
     417            'post_title'  => 'Test',
     418            'post_status' => 'draft',
     419        );
     420        $post_id = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
     421
     422        // Change the post's status to publish and date to future.
     423        $future_time = strtotime( '+1 day' );
     424        $future_date = new IXR_Date( $future_time );
     425        $new_post_content = array(
     426            'ID'          => $post_id,
     427            'post_title'  => 'Updated',
     428            'post_status' => 'publish',
     429            'post_date'   => $future_date,
     430        );
     431
     432        $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $new_post_content ) );
     433
     434        $after = get_post( $post_id );
     435        $this->assertEquals( 'future', $after->post_status );
     436
     437        $future_date_string = strftime( '%Y-%m-%d %H:%M:%S', $future_time );
     438        $this->assertEquals( $future_date_string, $after->post_date );
     439    }
    404440}
Note: See TracChangeset for help on using the changeset viewer.