- Timestamp:
- 11/10/2016 03:34:30 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php
r39158 r39196 930 930 } 931 931 932 public function test_create_item_invalid_ blank_content() {932 public function test_create_item_invalid_no_content() { 933 933 wp_set_current_user( 0 ); 934 934 … … 938 938 'author_email' => 'lovejoy@example.com', 939 939 'author_url' => 'http://timothylovejoy.jr', 940 'content' => '', 941 ); 942 943 $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); 944 $request->add_header( 'content-type', 'application/json' ); 945 $request->set_body( wp_json_encode( $params ) ); 946 940 ); 941 942 $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); 943 $request->add_header( 'content-type', 'application/json' ); 944 $request->set_body( wp_json_encode( $params ) ); 945 946 $response = $this->server->dispatch( $request ); 947 $this->assertErrorResponse( 'rest_comment_content_invalid', $response, 400 ); 948 949 $params['content'] = ''; 950 $request->set_body( wp_json_encode( $params ) ); 947 951 $response = $this->server->dispatch( $request ); 948 952 $this->assertErrorResponse( 'rest_comment_content_invalid', $response, 400 ); … … 1617 1621 $this->assertEquals( mysql_to_rfc3339( $updated->comment_date ), $comment['date'] ); 1618 1622 $this->assertEquals( '2014-11-07T10:14:25', $comment['date'] ); 1623 } 1624 1625 public function test_update_item_no_content() { 1626 $post_id = $this->factory->post->create(); 1627 1628 wp_set_current_user( self::$admin_id ); 1629 1630 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); 1631 $request->set_param( 'author_email', 'another@email.com' ); 1632 1633 // Sending a request without content is fine. 1634 $response = $this->server->dispatch( $request ); 1635 $this->assertEquals( 200, $response->get_status() ); 1636 1637 // Sending a request with empty comment is not fine. 1638 $request->set_param( 'author_email', 'yetanother@email.com' ); 1639 $request->set_param( 'content', '' ); 1640 $response = $this->server->dispatch( $request ); 1641 $this->assertErrorResponse( 'rest_comment_content_invalid', $response, 400 ); 1619 1642 } 1620 1643
Note: See TracChangeset
for help on using the changeset viewer.