- 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-block-type-controller.php
r59899 r59970 637 637 return null; 638 638 } 639 $this->assert Null($response->get_data(), 'The server should not generate a body in response to a HEAD request.' );639 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 640 640 } 641 641 … … 660 660 $response = rest_get_server()->dispatch( $request ); 661 661 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 662 $this->assertNull( $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 662 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 663 } 664 665 /** 666 * @dataProvider data_head_request_with_specified_fields_returns_success_response 667 * @ticket 56481 668 * 669 * @param string $path The path to test. 670 */ 671 public function test_head_request_with_specified_fields_returns_success_response( $path ) { 672 wp_set_current_user( self::$admin_id ); 673 $request = new WP_REST_Request( 'HEAD', $path ); 674 $request->set_param( '_fields', 'title' ); 675 $server = rest_get_server(); 676 $response = $server->dispatch( $request ); 677 add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 ); 678 $response = apply_filters( 'rest_post_dispatch', $response, $server, $request ); 679 remove_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10 ); 680 681 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 682 } 683 684 /** 685 * Data provider intended to provide paths for testing HEAD requests. 686 * 687 * @return array 688 */ 689 public static function data_head_request_with_specified_fields_returns_success_response() { 690 return array( 691 'get_item request' => array( '/wp/v2/block-types/fake/test' ), 692 'get_items request' => array( '/wp/v2/block-types' ), 693 ); 663 694 } 664 695
Note: See TracChangeset
for help on using the changeset viewer.