Ticket #38466: 38466.diff
File 38466.diff, 2.3 KB (added by , 9 years ago) |
---|
-
src/wp-includes/class-wp-xmlrpc-server.php
3553 3553 return new IXR_Error( 403, __( 'Sorry, comments are closed for this item.' ) ); 3554 3554 } 3555 3555 3556 $comment = array(); 3557 $comment['comment_post_ID'] = $post_id; 3556 if ( empty( $content_struct['content'] ) ) { 3557 return new IXR_Error( 403, __( 'Comment is required.' ) ); 3558 } 3559 3560 $comment = array( 3561 'comment_post_ID' => $post_id, 3562 'comment_content' => $content_struct['content'], 3563 ); 3558 3564 3559 3565 if ( $logged_in ) { 3560 3566 $display_name = $user->display_name; … … 3590 3596 3591 3597 $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; 3592 3598 3593 $comment['comment_content'] = isset($content_struct['content']) ? $content_struct['content'] : null;3594 3595 3599 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ 3596 3600 do_action( 'xmlrpc_call', 'wp.newComment' ); 3597 3601 -
tests/phpunit/tests/xmlrpc/wp/newComment.php
4 4 * @group xmlrpc 5 5 */ 6 6 class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { 7 8 function test_valid_comment() { 9 $this->make_user_by_role( 'administrator' ); 10 $post = self::factory()->post->create_and_get(); 11 12 $result = $this->myxmlrpcserver->wp_newComment( array( 1, 'administrator', 'administrator', $post->ID, array( 13 'content' => rand_str( 100 ) 14 ) ) ); 15 16 $this->assertNotInstanceOf( 'IXR_Error', $result ); 17 } 18 19 function test_empty_comment() { 20 $this->make_user_by_role( 'administrator' ); 21 $post = self::factory()->post->create_and_get(); 22 23 $result = $this->myxmlrpcserver->wp_newComment( array( 1, 'administrator', 'administrator', $post->ID, array( 24 'comment_content' => '' 25 ) ) ); 26 27 $this->assertInstanceOf( 'IXR_Error', $result ); 28 $this->assertEquals( 403, $result->code ); 29 } 30 7 31 function test_new_comment_post_closed() { 8 32 $this->make_user_by_role( 'administrator' ); 9 33 $post = self::factory()->post->create_and_get( array(