Make WordPress Core

Ticket #21397: patch-core-21397-2-tests.diff

File patch-core-21397-2-tests.diff, 1.3 KB (added by koke, 12 years ago)
  • tests/xmlrpc/wp/editPost.php

     
    221221                $this->assertFalse( is_sticky( $post_id ) );
    222222        }
    223223
     224  function test_only_if_no_new_revision() {
     225                $editor_id = $this->make_user_by_role( 'editor' );
     226
     227    $post = array(
     228      'post_title' => 'Post Revision Test',
     229      'post_author' => $editor_id,
     230      'post_status' => 'publish',
     231                        'post_date'  => strftime("%Y-%m-%d %H:%M:%S", strtotime( '-1 day' ) ),
     232    );
     233                $post_id = wp_insert_post( $post );
     234
     235    $revision_date = new IXR_Date( mysql2date( 'Ymd\TH:i:s', 'now', false ) );
     236    $post2 = array( 'post_content' => 'Edit #3', 'only_if_no_new_revision' => $revision_date );
     237                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) );
     238                $this->assertNotInstanceOf( 'IXR_Error', $result );
     239
     240    $revision_date = new IXR_Date( mysql2date( 'Ymd\TH:i:s', $post['post_date'], false ) );
     241    $post2 = array( 'post_content' => 'Edit #4', 'only_if_no_new_revision' => $revision_date );
     242                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) );
     243                $this->assertInstanceOf( 'IXR_Error', $result );
     244                $this->assertEquals( 409, $result->code );
     245  }
     246
    224247}