- 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-autosaves-controller.php
r59899 r59970 197 197 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 198 198 $this->assertSame( 0, $filter->get_call_count(), 'The "' . $hook_name . '" filter was called when it should not be for HEAD requests.' ); 199 $this->assert Null($response->get_data(), 'The server should not generate a body in response to a HEAD request.' );199 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 200 200 } 201 201 … … 315 315 return null; 316 316 } 317 $this->assert Null($response->get_data(), 'The server should not generate a body in response to a HEAD request.' );317 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 318 318 } 319 319 … … 890 890 $this->assertSame( $autosave['id'], $data['id'], 'Original autosave was not returned' ); 891 891 } 892 893 /** 894 * @dataProvider data_head_request_with_specified_fields_returns_success_response 895 * @ticket 56481 896 * 897 * @param string $path The path to test. 898 */ 899 public function test_head_request_with_specified_fields_returns_success_response( $path ) { 900 wp_set_current_user( self::$editor_id ); 901 $request = new WP_REST_Request( 'HEAD', sprintf( $path, self::$post_id, self::$autosave_post_id ) ); 902 $request->set_param( '_fields', 'id' ); 903 $server = rest_get_server(); 904 $response = $server->dispatch( $request ); 905 add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 ); 906 $response = apply_filters( 'rest_post_dispatch', $response, $server, $request ); 907 remove_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10 ); 908 909 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 910 } 911 912 /** 913 * Data provider intended to provide paths for testing HEAD requests. 914 * 915 * @return array 916 */ 917 public static function data_head_request_with_specified_fields_returns_success_response() { 918 return array( 919 'get_item request' => array( '/wp/v2/posts/%d/autosaves/%d' ), 920 'get_items request' => array( '/wp/v2/posts/%d' ), 921 ); 922 } 892 923 }
Note: See TracChangeset
for help on using the changeset viewer.