Skip to content

Commit

Permalink
Add unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-vlasenko committed Dec 26, 2024
1 parent 3085cc4 commit 63ce048
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,21 @@ public function test_get_items() {
$this->check_get_revision_response( $data[2], $this->revision_1 );
}

/**
* @ticket 56481
*
* @covers WP_REST_Global_Styles_Controller::prepare_item_for_response
*
* @param string $method The HTTP method to use.
*/
public function test_get_items_should_return_no_response_body_for_head_requests() {
wp_set_current_user( self::$admin_id );
$request = new WP_REST_Request( 'HEAD', '/wp/v2/global-styles/' . self::$global_styles_id . '/revisions' );
$response = rest_get_server()->dispatch( $request );
$this->assertSame( 200, $response->get_status(), 'Response status is 200.' );
$this->assertNull( $response->get_data(), 'The server should not generate a body in response to a HEAD request.' );
}

/**
* @ticket 59810
*
Expand All @@ -342,6 +357,21 @@ public function test_get_item() {
$this->check_get_revision_response( $data, $this->revision_1 );
}

/**
* @ticket 56481
*
* @covers WP_REST_Global_Styles_Controller::prepare_item_for_response
*
* @param string $method The HTTP method to use.
*/
public function test_get_item_should_return_no_response_body_for_head_requests() {
wp_set_current_user( self::$admin_id );
$request = new WP_REST_Request( 'HEAD', '/wp/v2/global-styles/' . self::$global_styles_id . '/revisions/' . $this->revision_1_id );
$response = rest_get_server()->dispatch( $request );
$this->assertSame( 200, $response->get_status(), 'Response status is 200.' );
$this->assertNull( $response->get_data(), 'The server should not generate a body in response to a HEAD request.' );
}

/**
* @dataProvider data_readable_http_methods
* @ticket 59810
Expand Down

0 comments on commit 63ce048

Please sign in to comment.