From d4ea5a8c882d3ef14954e1f41434991e77279a4a Mon Sep 17 00:00:00 2001 From: ramon Date: Thu, 29 Jun 2023 12:39:21 +1000 Subject: [PATCH 1/3] Implementing feedback from https://github.com/WordPress/wordpress-develop/pull/4606 Formatting and test annotations to include @covers --- ...class-wp-rest-global-styles-controller.php | 6 +- ...est-global-styles-revisions-controller.php | 56 ++++++++++++++----- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php index f64afba1baa2a..cccb7b3a3d35e 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php @@ -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, diff --git a/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php b/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php index 127e638b772e9..78aa86b20422c 100644 --- a/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php +++ b/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php @@ -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(); @@ -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 ); @@ -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 ); @@ -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 ); @@ -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 ); @@ -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' ); @@ -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 ); @@ -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 ); @@ -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 ); @@ -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 ); @@ -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 ); @@ -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 ); @@ -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 ); @@ -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 ); @@ -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 ); @@ -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 ); @@ -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 ); @@ -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 ); @@ -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 ); @@ -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 ); @@ -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 ); From 15249a1f070bd5783b462b0968592864187cd4f0 Mon Sep 17 00:00:00 2001 From: ramon Date: Thu, 29 Jun 2023 12:53:12 +1000 Subject: [PATCH 2/3] space --- .../tests/rest-api/rest-global-styles-revisions-controller.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php b/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php index 78aa86b20422c..f9799bf123424 100644 --- a/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php +++ b/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php @@ -66,7 +66,6 @@ class WP_REST_Global_Styles_Revisions_Controller_Test extends WP_Test_REST_Contr */ private $revision_3_id; - /** * Create fake data before our tests run. * From 3428239af162708eed394fa26f5a4c833ab9cbbe Mon Sep 17 00:00:00 2001 From: ramon Date: Thu, 29 Jun 2023 12:58:29 +1000 Subject: [PATCH 3/3] spaces --- .../tests/rest-api/rest-global-styles-revisions-controller.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php b/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php index f9799bf123424..9e580d5f3c978 100644 --- a/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php +++ b/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php @@ -224,7 +224,6 @@ public function set_up() { $this->revision_3_id = $this->revision_3->ID; } - /** * @ticket 58524 * @@ -569,7 +568,6 @@ public function test_get_items_default_query_should_fetch_all_revisons() { $this->assertCount( $expected_count, $response->get_data() ); } - /** * Tests that 'offset' query shouldn't work without 'per_page' (fallback -1). *