- 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-revisions-controller.php
r59899 r59970 183 183 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 184 184 $this->assertSame( 0, $filter->get_call_count(), 'The "' . $hook_name . '" filter was called when it should not be for HEAD requests.' ); 185 $this->assert Null($response->get_data(), 'The server should not generate a body in response to a HEAD request.' );185 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 186 186 } 187 187 … … 301 301 return null; 302 302 } 303 $this->assertNull( $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 303 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 304 } 305 306 /** 307 * @dataProvider data_head_request_with_specified_fields_returns_success_response 308 * @ticket 56481 309 * 310 * @param string $path The path to test. 311 */ 312 public function test_head_request_with_specified_fields_returns_success_response( $path ) { 313 wp_set_current_user( self::$editor_id ); 314 $request = new WP_REST_Request( 'HEAD', sprintf( $path, self::$post_id, $this->revision_id1 ) ); 315 $request->set_param( '_fields', 'id' ); 316 $server = rest_get_server(); 317 $response = $server->dispatch( $request ); 318 add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 ); 319 $response = apply_filters( 'rest_post_dispatch', $response, $server, $request ); 320 remove_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10 ); 321 322 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 323 } 324 325 /** 326 * Data provider intended to provide paths for testing HEAD requests. 327 * 328 * @return array 329 */ 330 public static function data_head_request_with_specified_fields_returns_success_response() { 331 return array( 332 333 'get_item request' => array( '/wp/v2/posts/%d/revisions/%d' ), 334 'get_items request' => array( '/wp/v2/posts/%d/revisions' ), 335 ); 304 336 } 305 337
Note: See TracChangeset
for help on using the changeset viewer.