Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rest API: updating test annotations for global styles revisions #4750

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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.
*
Expand Down Expand Up @@ -225,11 +224,10 @@ public function set_up() {
$this->revision_3_id = $this->revision_3->ID;
}


/**
* @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 +239,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 +279,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 +305,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 +337,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 +358,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 +381,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 +399,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 +438,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 +476,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 +498,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 +527,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 +555,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 @@ -558,13 +568,14 @@ 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).
*
* 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 +595,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 +622,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 +651,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 +679,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 +707,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 +735,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 +764,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