After [33325], supply a missing `post_type` in `->mw_editPost()`.

Add unit test.

Props ocean90.
Fixes #20662.


git-svn-id: https://develop.svn.wordpress.org/trunk@33612 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2015-08-13 15:27:57 +00:00
parent ee67bd08f9
commit df480edb24
2 changed files with 16 additions and 1 deletions

View File

@ -5281,6 +5281,7 @@ class wp_xmlrpc_server extends IXR_Server {
if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) {
$data = $newpost; $data = $newpost;
$data['sticky'] = $content_struct['sticky']; $data['sticky'] = $content_struct['sticky'];
$data['post_type'] = 'post';
$error = $this->_toggle_sticky( $data, true ); $error = $this->_toggle_sticky( $data, true );
if ( $error ) { if ( $error ) {
return $error; return $error;

View File

@ -113,7 +113,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase {
$out = get_post( $post_id ); $out = get_post( $post_id );
$this->assertEquals( $editor_id, $out->post_author ); $this->assertEquals( $editor_id, $out->post_author );
} }
function test_post_thumbnail() { function test_post_thumbnail() {
add_theme_support( 'post-thumbnails' ); add_theme_support( 'post-thumbnails' );
@ -203,6 +203,20 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase {
$this->assertEquals( $post4['mt_excerpt'], $out->post_excerpt ); $this->assertEquals( $post4['mt_excerpt'], $out->post_excerpt );
} }
/**
* @ticket 20662
*/
function test_make_post_sticky() {
$author_id = $this->make_user_by_role( 'editor' );
$post = array( 'post_title' => 'Title', 'post_content' => 'Content', 'post_author' => $author_id, 'post_status' => 'publish' );
$post_id = wp_insert_post( $post );
$result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', array( 'sticky' => '1' ) ) );
$this->assertNotInstanceOf( 'IXR_Error', $result );
$this->assertTrue( $result );
}
// Not allowed since [19914] // Not allowed since [19914]
function test_change_post_type() { function test_change_post_type() {
$contributor_id = $this->make_user_by_role( 'contributor' ); $contributor_id = $this->make_user_by_role( 'contributor' );