- 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-tags-controller.php
r59899 r59970 1615 1615 return null; 1616 1616 } 1617 $this->assertNull( $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 1617 $this->assertSame( array(), $response->get_data(), 'The server should not generate a body in response to a HEAD request.' ); 1618 } 1619 1620 /** 1621 * @dataProvider data_head_request_with_specified_fields_returns_success_response 1622 * @ticket 56481 1623 * 1624 * @param string $path The path to test. 1625 */ 1626 public function test_head_request_with_specified_fields_returns_success_response( $path ) { 1627 $tag_id = self::factory()->tag->create(); 1628 $request = new WP_REST_Request( 'HEAD', sprintf( $path, $tag_id ) ); 1629 $request->set_param( '_fields', 'id' ); 1630 $server = rest_get_server(); 1631 $response = $server->dispatch( $request ); 1632 add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 ); 1633 $response = apply_filters( 'rest_post_dispatch', $response, $server, $request ); 1634 remove_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10 ); 1635 1636 $this->assertSame( 200, $response->get_status(), 'The response status should be 200.' ); 1637 } 1638 1639 /** 1640 * Data provider intended to provide paths for testing HEAD requests. 1641 * 1642 * @return array 1643 */ 1644 public static function data_head_request_with_specified_fields_returns_success_response() { 1645 return array( 1646 'get_item request' => array( '/wp/v2/tags/%d' ), 1647 'get_items request' => array( '/wp/v2/tags' ), 1648 ); 1618 1649 } 1619 1650 }
Note: See TracChangeset
for help on using the changeset viewer.