WordPress.org

Make WordPress Core

Changeset 1109 in tests


Ignore:
Timestamp:
11/03/2012 03:42:20 PM (6 years ago)
Author:
markoheijnen
Message:

XML-RPC: Updated tests for wp.editPost when user tries to modify an attachment

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/xmlrpc/wp/editPost.php

    r1049 r1109  
    252252        $this->assertEquals( 'First edit', get_post( $post_id )->post_content );
    253253    }
     254
     255    function test_edit_attachment() {
     256        $editor_id = $this->make_user_by_role( 'editor' );
     257
     258        $post_id = $this->factory->post->create( array(
     259            'post_title'   => 'Post Revision Test',
     260            'post_content' => 'Not edited',
     261            'post_status'  => 'inherit',
     262            'post_type'    => 'attachment',
     263            'post_author'  => $editor_id,
     264        ) );
     265
     266        $struct = array( 'post_content' => 'First edit' );
     267        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) );
     268        $this->assertNotInstanceOf( 'IXR_Error', $result );
     269
     270        // Make sure that the post status is still inherit
     271        $this->assertEquals( 'inherit', get_post( $post_id )->post_status );
     272    }
     273
     274    function test_use_invalid_post_status() {
     275        $editor_id = $this->make_user_by_role( 'editor' );
     276
     277        $post_id = $this->factory->post->create( array(
     278            'post_title'   => 'Post Revision Test',
     279            'post_content' => 'Not edited',
     280            'post_author'  => $editor_id,
     281        ) );
     282
     283        $struct = array( 'post_status' => 'doesnt_exists' );
     284        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) );
     285        $this->assertNotInstanceOf( 'IXR_Error', $result );
     286
     287        // Make sure that the post status is still inherit
     288        $this->assertEquals( 'draft', get_post( $post_id )->post_status );
     289    }
    254290}
Note: See TracChangeset for help on using the changeset viewer.