- 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-sidebars-controller.php
r59899 r59970 172 172 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 173 173 $this->assertSame( 0, $filter->get_call_count(), 'The "' . $hook_name . '" filter was called when it should not be for HEAD requests.' ); 174 $this->assert Null($response->get_data(), 'The server should not generate a body in response to a HEAD request.' );174 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 175 175 } 176 176 … … 568 568 return null; 569 569 } 570 $this->assertNull( $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 570 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 571 } 572 573 /** 574 * @dataProvider data_head_request_with_specified_fields_returns_success_response 575 * @ticket 56481 576 * 577 * @param string $path The path to test. 578 */ 579 public function test_head_request_with_specified_fields_returns_success_response( $path ) { 580 $this->setup_sidebar( 581 'sidebar-1', 582 array( 583 'name' => 'Test sidebar', 584 ) 585 ); 586 587 $request = new WP_REST_Request( 'HEAD', $path ); 588 // This endpoint doesn't seem to support _fields param, but we need to set it to reproduce the fatal error. 589 $request->set_param( '_fields', 'name' ); 590 $server = rest_get_server(); 591 $response = $server->dispatch( $request ); 592 add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 ); 593 $response = apply_filters( 'rest_post_dispatch', $response, $server, $request ); 594 remove_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10 ); 595 596 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 597 } 598 599 /** 600 * Data provider intended to provide paths for testing HEAD requests. 601 * 602 * @return array 603 */ 604 public static function data_head_request_with_specified_fields_returns_success_response() { 605 return array( 606 607 'get_item request' => array( '/wp/v2/sidebars/sidebar-1' ), 608 'get_items request' => array( '/wp/v2/sidebars' ), 609 ); 571 610 } 572 611
Note: See TracChangeset
for help on using the changeset viewer.