- Timestamp:
- 03/11/2025 02:17:41 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-widget-types-controller.php
r59899 r59970 130 130 $response = rest_get_server()->dispatch( $request ); 131 131 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 132 $this->assert Null($response->get_data(), 'The server should not generate a body in response to a HEAD request.' );132 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 133 133 } 134 134 … … 228 228 return null; 229 229 } 230 $this->assert Null($response->get_data(), 'The server should not generate a body in response to a HEAD request.' );230 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 231 231 } 232 232 … … 240 240 'GET request' => array( 'GET' ), 241 241 'HEAD request' => array( 'HEAD' ), 242 ); 243 } 244 245 /** 246 * @dataProvider data_head_request_with_specified_fields_returns_success_response 247 * @ticket 56481 248 * 249 * @param string $path The path to test. 250 */ 251 public function test_head_request_with_specified_fields_returns_success_response( $path ) { 252 wp_set_current_user( self::$admin_id ); 253 $request = new WP_REST_Request( 'HEAD', $path ); 254 $request->set_param( '_fields', 'id' ); 255 $server = rest_get_server(); 256 $response = $server->dispatch( $request ); 257 add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 ); 258 $response = apply_filters( 'rest_post_dispatch', $response, $server, $request ); 259 remove_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10 ); 260 261 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 262 } 263 264 /** 265 * Data provider intended to provide paths for testing HEAD requests. 266 * 267 * @return array 268 */ 269 public static function data_head_request_with_specified_fields_returns_success_response() { 270 return array( 271 'get_item request' => array( '/wp/v2/widget-types/calendar' ), 272 'get_items request' => array( '/wp/v2/widget-types' ), 242 273 ); 243 274 }
Note: See TracChangeset
for help on using the changeset viewer.