- Timestamp:
- 03/11/2025 02:17:41 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/wpRestTemplatesController.php
r59899 r59970 186 186 $response = rest_get_server()->dispatch( $request ); 187 187 $this->assertSame( 200, $response->get_status(), 'Response status is 200.' ); 188 $this->assertNull( $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 188 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 189 } 190 191 /** 192 * @dataProvider data_head_request_with_specified_fields_returns_success_response 193 * @ticket 56481 194 * 195 * @param string $path The path to test. 196 */ 197 public function test_head_request_with_specified_fields_returns_success_response( $path ) { 198 wp_set_current_user( self::$admin_id ); 199 $request = new WP_REST_Request( 'HEAD', $path ); 200 $request->set_param( '_fields', 'id' ); 201 $server = rest_get_server(); 202 $response = $server->dispatch( $request ); 203 add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 ); 204 $response = apply_filters( 'rest_post_dispatch', $response, $server, $request ); 205 remove_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10 ); 206 207 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 208 } 209 210 /** 211 * Data provider intended to provide paths for testing HEAD requests. 212 * 213 * @return array 214 */ 215 public static function data_head_request_with_specified_fields_returns_success_response() { 216 return array( 217 'get_item request' => array( '/wp/v2/templates/default//my_template' ), 218 'get_items request' => array( '/wp/v2/templates' ), 219 ); 189 220 } 190 221 … … 292 323 $response = rest_get_server()->dispatch( $request ); 293 324 $this->assertSame( 200, $response->get_status(), 'Response status is 200.' ); 294 $this->assert Null($response->get_data(), 'The server should not generate a body in response to a HEAD request.' );325 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 295 326 } 296 327
Note: See TracChangeset
for help on using the changeset viewer.