- 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-post-types-controller.php
r59899 r59970 112 112 return null; 113 113 } 114 $this->assertNull( $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 114 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 115 } 116 117 /** 118 * @dataProvider data_head_request_with_specified_fields_returns_success_response 119 * @ticket 56481 120 * 121 * @param string $path The path to test. 122 */ 123 public function test_head_request_with_specified_fields_returns_success_response( $path ) { 124 $request = new WP_REST_Request( 'HEAD', $path ); 125 $request->set_param( '_fields', 'slug' ); 126 $server = rest_get_server(); 127 $response = $server->dispatch( $request ); 128 add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 ); 129 $response = apply_filters( 'rest_post_dispatch', $response, $server, $request ); 130 remove_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10 ); 131 132 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 133 } 134 135 /** 136 * Data provider intended to provide paths for testing HEAD requests. 137 * 138 * @return array 139 */ 140 public static function data_head_request_with_specified_fields_returns_success_response() { 141 return array( 142 'get_item request' => array( '/wp/v2/types/post' ), 143 'get_items request' => array( '/wp/v2/types' ), 144 ); 115 145 } 116 146 … … 325 355 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 326 356 $this->assertSame( 0, $filter->get_call_count(), 'The "' . $hook_name . '" filter was called when it should not be for HEAD requests.' ); 327 $this->assert Null($response->get_data(), 'The server should not generate a body in response to a HEAD request.' );357 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 328 358 } 329 359
Note: See TracChangeset
for help on using the changeset viewer.