- 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-categories-controller.php
r59899 r59970 1361 1361 return null; 1362 1362 } 1363 $this->assertNull( $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 1363 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 1364 } 1365 1366 /** 1367 * @dataProvider data_head_request_with_specified_fields_returns_success_response 1368 * @ticket 56481 1369 * 1370 * @param string $path The path to test. 1371 */ 1372 public function test_head_request_with_specified_fields_returns_success_response( $path ) { 1373 $request = new WP_REST_Request( 'HEAD', $path ); 1374 $request->set_param( '_fields', 'id' ); 1375 $server = rest_get_server(); 1376 $response = $server->dispatch( $request ); 1377 add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 ); 1378 $response = apply_filters( 'rest_post_dispatch', $response, $server, $request ); 1379 remove_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10 ); 1380 1381 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 1382 } 1383 1384 /** 1385 * Data provider intended to provide paths for testing HEAD requests. 1386 * 1387 * @return array 1388 */ 1389 public static function data_head_request_with_specified_fields_returns_success_response() { 1390 return array( 1391 'get_item request' => array( '/wp/v2/categories/1' ), 1392 'get_items request' => array( '/wp/v2/categories' ), 1393 ); 1364 1394 } 1365 1395 }
Note: See TracChangeset
for help on using the changeset viewer.