Skip to content

Commit

Permalink
Implementing feedback from WordPress#4606
Browse files Browse the repository at this point in the history
Formatting and test annotations to include @Covers
  • Loading branch information
ramonjd committed Jun 29, 2023
1 parent 91a95fe commit d4ea5a8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,9 @@ protected function prepare_links( $id ) {
);

if ( post_type_supports( $this->post_type, 'revisions' ) ) {
$revisions = wp_get_latest_revision_id_and_total_count( $id );
$revisions_count = ! is_wp_error( $revisions ) ? $revisions['count'] : 0;
$revisions_base = sprintf( '/%s/%d/revisions', $base, $id );
$revisions = wp_get_latest_revision_id_and_total_count( $id );
$revisions_count = ! is_wp_error( $revisions ) ? $revisions['count'] : 0;
$revisions_base = sprintf( '/%s/%d/revisions', $base, $id );
$links['version-history'] = array(
'href' => rest_url( $revisions_base ),
'count' => $revisions_count,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ public function set_up() {


/**
* @covers WP_REST_Global_Styles_Controller::register_routes
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::register_routes
*/
public function test_register_routes() {
$routes = rest_get_server()->get_routes();
Expand All @@ -241,9 +241,9 @@ public function test_register_routes() {
}

/**
* @covers WP_REST_Global_Styles_Controller::get_items
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items
*/
public function test_get_items_missing_parent() {
wp_set_current_user( self::$admin_id );
Expand Down Expand Up @@ -281,9 +281,9 @@ protected function check_get_revision_response( $response_revision_item, $revisi
}

/**
* @covers WP_REST_Global_Styles_Controller::get_items
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items
*/
public function test_get_items() {
wp_set_current_user( self::$admin_id );
Expand All @@ -307,9 +307,9 @@ public function test_get_items() {
}

/**
* @covers WP_REST_Global_Styles_Controller::get_items
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items
*/
public function test_get_items_eligible_roles() {
wp_set_current_user( self::$second_admin_id );
Expand Down Expand Up @@ -339,9 +339,9 @@ public function test_get_items_eligible_roles() {
}

/**
* @covers WP_REST_Global_Styles_Controller::get_items with context arg.
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items with context arg.
*/
public function test_get_item_embed_context() {
wp_set_current_user( self::$admin_id );
Expand All @@ -360,9 +360,9 @@ public function test_get_item_embed_context() {
}

/**
* @covers WP_REST_Global_Styles_Controller::get_item_schema
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_item_schema
*/
public function test_get_item_schema() {
$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/global-styles/' . self::$global_styles_id . '/revisions' );
Expand All @@ -383,9 +383,9 @@ public function test_get_item_schema() {
}

/**
* @covers WP_REST_Global_Styles_Controller::get_item_permissions_check
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_item_permissions_check
*/
public function test_get_item_permissions_check() {
wp_set_current_user( self::$author_id );
Expand All @@ -401,6 +401,8 @@ public function test_get_item_permissions_check() {
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_pagination_header_of_the_first_page
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items
*/
public function test_get_items_pagination_header_of_the_first_page() {
wp_set_current_user( self::$admin_id );
Expand Down Expand Up @@ -438,6 +440,8 @@ public function test_get_items_pagination_header_of_the_first_page() {
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_pagination_header_of_the_last_page
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items
*/
public function test_get_items_pagination_header_of_the_last_page() {
wp_set_current_user( self::$admin_id );
Expand Down Expand Up @@ -474,6 +478,8 @@ public function test_get_items_pagination_header_of_the_last_page() {
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_invalid_per_page_should_error
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items
*/
public function test_get_items_invalid_per_page_should_error() {
wp_set_current_user( self::$admin_id );
Expand All @@ -494,6 +500,8 @@ public function test_get_items_invalid_per_page_should_error() {
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_out_of_bounds_page_should_error
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items
*/
public function test_get_items_out_of_bounds_page_should_error() {
wp_set_current_user( self::$admin_id );
Expand Down Expand Up @@ -521,6 +529,8 @@ public function test_get_items_out_of_bounds_page_should_error() {
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_invalid_max_pages_should_error
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items
*/
public function test_get_items_invalid_max_pages_should_error() {
wp_set_current_user( self::$admin_id );
Expand All @@ -547,6 +557,8 @@ public function test_get_items_invalid_max_pages_should_error() {
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_default_query_should_fetch_all_revisons
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items
*/
public function test_get_items_default_query_should_fetch_all_revisons() {
wp_set_current_user( self::$admin_id );
Expand All @@ -565,6 +577,8 @@ public function test_get_items_default_query_should_fetch_all_revisons() {
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_offset_should_not_work_without_per_page
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items
*/
public function test_get_items_offset_should_not_work_without_per_page() {
wp_set_current_user( self::$admin_id );
Expand All @@ -584,6 +598,8 @@ public function test_get_items_offset_should_not_work_without_per_page() {
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_offset_should_work_with_per_page
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items
*/
public function test_get_items_offset_should_work_with_per_page() {
wp_set_current_user( self::$admin_id );
Expand All @@ -609,6 +625,8 @@ public function test_get_items_offset_should_work_with_per_page() {
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_offset_should_take_priority_over_page
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items
*/
public function test_get_items_offset_should_take_priority_over_page() {
wp_set_current_user( self::$admin_id );
Expand Down Expand Up @@ -636,6 +654,8 @@ public function test_get_items_offset_should_take_priority_over_page() {
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_total_revisions_offset_should_return_empty_data
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items
*/
public function test_get_items_total_revisions_offset_should_return_empty_data() {
wp_set_current_user( self::$admin_id );
Expand All @@ -662,6 +682,8 @@ public function test_get_items_total_revisions_offset_should_return_empty_data()
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_out_of_bound_offset_should_error
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items
*/
public function test_get_items_out_of_bound_offset_should_error() {
wp_set_current_user( self::$admin_id );
Expand All @@ -688,6 +710,8 @@ public function test_get_items_out_of_bound_offset_should_error() {
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_impossible_high_number_offset_should_error
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items
*/
public function test_get_items_impossible_high_number_offset_should_error() {
wp_set_current_user( self::$admin_id );
Expand All @@ -714,6 +738,8 @@ public function test_get_items_impossible_high_number_offset_should_error() {
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_invalid_offset_should_error
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items
*/
public function test_get_items_invalid_offset_should_error() {
wp_set_current_user( self::$admin_id );
Expand Down Expand Up @@ -741,6 +767,8 @@ public function test_get_items_invalid_offset_should_error() {
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_out_of_bounds_page_should_not_error_if_offset
*
* @ticket 58524
*
* @covers WP_REST_Global_Styles_Controller::get_items
*/
public function test_get_items_out_of_bounds_page_should_not_error_if_offset() {
wp_set_current_user( self::$admin_id );
Expand Down

0 comments on commit d4ea5a8

Please sign in to comment.