Changeset 40113
- Timestamp:
- 02/24/2017 08:56:00 PM (8 years ago)
- Location:
- branches/4.7
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.7
-
branches/4.7/src/wp-includes/rest-api/class-wp-rest-request.php
r39642 r40113 365 365 } 366 366 367 $accepts_body_data = array( 'POST', 'PUT', 'PATCH' );367 $accepts_body_data = array( 'POST', 'PUT', 'PATCH', 'DELETE' ); 368 368 if ( in_array( $this->method, $accepts_body_data ) ) { 369 369 $order[] = 'POST'; -
branches/4.7/tests/phpunit/tests/rest-api/rest-request.php
r39642 r40113 204 204 } 205 205 206 public function non_post_http_methods_with_request_body_provider() { 207 return array( 208 array( 'PUT' ), 209 array( 'PATCH' ), 210 array( 'DELETE' ), 211 ); 212 } 213 206 214 /** 207 * PUT requests don't get $_POST automatically parsed, so ensure that 208 * WP_REST_Request does it for us. 215 * Tests that methods supporting request bodies have access to the 216 * request's body. For POST this is straightforward via `$_POST`; for 217 * other methods `WP_REST_Request` needs to parse the body for us. 218 * 219 * @dataProvider non_post_http_methods_with_request_body_provider 209 220 */ 210 public function test_ parameters_for_put() {221 public function test_non_post_body_parameters( $request_method ) { 211 222 $data = array( 212 223 'foo' => 'bar', … … 220 231 ), 221 232 ); 222 223 $this->request->set_method( 'PUT' ); 233 $this->request->set_method( $request_method ); 224 234 $this->request->set_body_params( array() ); 225 235 $this->request->set_body( http_build_query( $data ) ); 226 227 236 foreach ( $data as $key => $expected_value ) { 228 237 $this->assertEquals( $expected_value, $this->request->get_param( $key ) );
Note: See TracChangeset
for help on using the changeset viewer.