- Timestamp:
- 06/24/2020 12:03:33 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php
r47122 r48154 2791 2791 } 2792 2792 2793 /** 2794 * @ticket 39732 2795 */ 2796 public function test_update_comment_is_wp_error() { 2797 wp_set_current_user( self::$admin_id ); 2798 2799 $params = array( 2800 'content' => 'This isn\'t a saxophone. It\'s an umbrella.', 2801 ); 2802 2803 add_filter( 'wp_update_comment_data', array( $this, '_wp_update_comment_data_filter' ), 10, 3 ); 2804 2805 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); 2806 2807 $request->add_header( 'content-type', 'application/json' ); 2808 $request->set_body( wp_json_encode( $params ) ); 2809 $response = rest_get_server()->dispatch( $request ); 2810 2811 $this->assertErrorResponse( 'rest_comment_failed_edit', $response, 500 ); 2812 2813 remove_filter( 'wp_update_comment_data', array( $this, '_wp_update_comment_data_filter' ), 10, 3 ); 2814 } 2815 2816 /** 2817 * Block comments from being updated by returning WP_Error 2818 */ 2819 public function _wp_update_comment_data_filter( $data, $comment, $commentarr ) { 2820 return new WP_Error( 'comment_wrong', __( 'wp_update_comment_data filter fails for this comment.' ), array( 'status' => 500 ) ); 2821 } 2822 2793 2823 public function verify_comment_roundtrip( $input = array(), $expected_output = array() ) { 2794 2824 // Create the comment.
Note: See TracChangeset
for help on using the changeset viewer.