- Timestamp:
- 03/11/2025 02:17:41 PM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php
r59899 r59970 337 337 $response = rest_get_server()->dispatch( $request ); 338 338 $this->assertSame( 200, $response->get_status(), 'Response status is 200.' ); 339 $this->assertNull( $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 339 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 340 } 341 342 /** 343 * @dataProvider data_head_request_with_specified_fields_returns_success_response 344 * @ticket 56481 345 * 346 * @param string $path The path to test. 347 */ 348 public function test_head_request_with_specified_fields_returns_success_response( $path ) { 349 wp_set_current_user( self::$admin_id ); 350 $request = new WP_REST_Request( 'GET', sprintf( $path, self::$global_styles_id, $this->revision_1_id ) ); 351 $request->set_param( '_fields', 'id' ); 352 $server = rest_get_server(); 353 $response = $server->dispatch( $request ); 354 add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 ); 355 $response = apply_filters( 'rest_post_dispatch', $response, $server, $request ); 356 remove_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10 ); 357 358 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 359 } 360 361 /** 362 * Data provider intended to provide paths for testing HEAD requests. 363 * 364 * @return array 365 */ 366 public static function data_head_request_with_specified_fields_returns_success_response() { 367 return array( 368 'get_item request' => array( '/wp/v2/global-styles/%d/revisions/%d' ), 369 'get_items request' => array( '/wp/v2/global-styles/%d/revisions' ), 370 ); 340 371 } 341 372 … … 367 398 $response = rest_get_server()->dispatch( $request ); 368 399 $this->assertSame( 200, $response->get_status(), 'Response status is 200.' ); 369 $this->assert Null($response->get_data(), 'The server should not generate a body in response to a HEAD request.' );400 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 370 401 } 371 402
Note: See TracChangeset
for help on using the changeset viewer.