- 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-taxonomies-controller.php
r59899 r59970 74 74 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 75 75 $this->assertSame( 0, $filter->get_call_count(), 'The "' . $hook_name . '" filter was called when it should not be for HEAD requests.' ); 76 $this->assert Null($response->get_data(), 'The server should not generate a body in response to a HEAD request.' );76 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 77 77 } 78 78 … … 186 186 return null; 187 187 } 188 $this->assertNull( $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 188 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 189 } 190 191 /** 192 * @dataProvider data_head_request_with_specified_fields_returns_success_response 193 * @ticket 56481 194 * 195 * @param string $path The path to test. 196 */ 197 public function test_head_request_with_specified_fields_returns_success_response( $path ) { 198 $request = new WP_REST_Request( 'HEAD', $path ); 199 $request->set_param( '_fields', 'name' ); 200 $server = rest_get_server(); 201 $response = $server->dispatch( $request ); 202 add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 ); 203 $response = apply_filters( 'rest_post_dispatch', $response, $server, $request ); 204 remove_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10 ); 205 206 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 207 } 208 209 /** 210 * Data provider intended to provide paths for testing HEAD requests. 211 * 212 * @return array 213 */ 214 public static function data_head_request_with_specified_fields_returns_success_response() { 215 return array( 216 'get_item request' => array( '/wp/v2/taxonomies/category' ), 217 'get_items request' => array( '/wp/v2/taxonomies' ), 218 ); 189 219 } 190 220
Note: See TracChangeset
for help on using the changeset viewer.