Skip to content

Commit

Permalink
Updated annotations that refer to duplicates
Browse files Browse the repository at this point in the history
reformatting functions in test
  • Loading branch information
ramonjd committed Jun 23, 2023
1 parent 09a9053 commit de82ac9
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public function __construct() {

/**
* Registers the controllers routes.
*
* @return void
*/
public function register_routes() {
register_rest_route(
Expand Down Expand Up @@ -252,10 +250,11 @@ public function get_items( $request ) {
}

/**
* A direct copy of WP_REST_Revisions_Controller->prepare_date_response().
* Checks the post_date_gmt or modified_gmt and prepare any post or
* modified date for single post output.
*
* Duplicate of WP_REST_Revisions_Controller::prepare_date_response
*
* @since 6.3.0
*
* @param string $date_gmt GMT publication time.
Expand Down Expand Up @@ -438,7 +437,7 @@ public function get_item_permissions_check( $request ) {
}

/*
* The same check as WP_REST_Global_Styles_Controller->get_item_permissions_check.
* The same check as WP_REST_Global_Styles_Controller::get_item_permissions_check.
*/
if ( ! current_user_can( 'read_post', $post->ID ) ) {
return new WP_Error(
Expand All @@ -452,7 +451,9 @@ public function get_item_permissions_check( $request ) {
}

/**
* Get the parent post, if the ID is valid. Copied from WP_REST_Revisions_Controller.
* Get the parent post, if the ID is valid.
*
* Duplicate of WP_REST_Revisions_Controller::get_parent
*
* @since 6.3.0
*
Expand Down
166 changes: 100 additions & 66 deletions tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,84 +107,90 @@ public static function wpSetupBeforeClass( $factory ) {
// Update post to create a new revisions.
$new_styles_post = array(
'ID' => self::$global_styles_id,
'post_content' => wp_json_encode( array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'isGlobalStylesUserThemeJSON' => true,
'styles' => array(
'color' => array(
'background' => 'hotpink',
'post_content' => wp_json_encode(
array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'isGlobalStylesUserThemeJSON' => true,
'styles' => array(
'color' => array(
'background' => 'hotpink',
),
),
),
'settings' => array(
'color' => array(
'palette' => array(
'custom' => array(
array(
'name' => 'Ghost',
'slug' => 'ghost',
'color' => 'ghost',
'settings' => array(
'color' => array(
'palette' => array(
'custom' => array(
array(
'name' => 'Ghost',
'slug' => 'ghost',
'color' => 'ghost',
),
),
),
),
),
),
) ),
)
),
);

wp_update_post( $new_styles_post, true, false );

$new_styles_post = array(
'ID' => self::$global_styles_id,
'post_content' => wp_json_encode( array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'isGlobalStylesUserThemeJSON' => true,
'styles' => array(
'color' => array(
'background' => 'lemonchiffon',
'post_content' => wp_json_encode(
array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'isGlobalStylesUserThemeJSON' => true,
'styles' => array(
'color' => array(
'background' => 'lemonchiffon',
),
),
),
'settings' => array(
'color' => array(
'palette' => array(
'custom' => array(
array(
'name' => 'Gwanda',
'slug' => 'gwanda',
'color' => 'gwanda',
'settings' => array(
'color' => array(
'palette' => array(
'custom' => array(
array(
'name' => 'Gwanda',
'slug' => 'gwanda',
'color' => 'gwanda',
),
),
),
),
),
),
) ),
)
),
);

wp_update_post( $new_styles_post, true, false );

$new_styles_post = array(
'ID' => self::$global_styles_id,
'post_content' => wp_json_encode( array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'isGlobalStylesUserThemeJSON' => true,
'styles' => array(
'color' => array(
'background' => 'chocolate',
'post_content' => wp_json_encode(
array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'isGlobalStylesUserThemeJSON' => true,
'styles' => array(
'color' => array(
'background' => 'chocolate',
),
),
),
'settings' => array(
'color' => array(
'palette' => array(
'custom' => array(
array(
'name' => 'Stacy',
'slug' => 'stacy',
'color' => 'stacy',
'settings' => array(
'color' => array(
'palette' => array(
'custom' => array(
array(
'name' => 'Stacy',
'slug' => 'stacy',
'color' => 'stacy',
),
),
),
),
),
),
) ),
)
),
);

wp_update_post( $new_styles_post, true, false );
Expand Down Expand Up @@ -389,7 +395,9 @@ public function test_get_item_permissions_check() {
}

/**
* Test the pagination header of the first page.
* Tests the pagination header of the first page.
*
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_pagination_header_of_the_first_page
*
* @ticket 58524
*/
Expand Down Expand Up @@ -424,7 +432,9 @@ public function test_get_items_pagination_header_of_the_first_page() {
}

/**
* Test the pagination header of the last page.
* Tests the pagination header of the last page.
*
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_pagination_header_of_the_last_page
*
* @ticket 58524
*/
Expand Down Expand Up @@ -458,7 +468,9 @@ public function test_get_items_pagination_header_of_the_last_page() {
}

/**
* Test that invalid 'per_page' query should error.
* Tests that invalid 'per_page' query should error.
*
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_invalid_per_page_should_error
*
* @ticket 58524
*/
Expand All @@ -476,7 +488,9 @@ public function test_get_items_invalid_per_page_should_error() {
}

/**
* Test that out of bounds 'page' query should error.
* Tests that out of bounds 'page' query should error.
*
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_out_of_bounds_page_should_error
*
* @ticket 58524
*/
Expand All @@ -501,7 +515,9 @@ public function test_get_items_out_of_bounds_page_should_error() {
}

/**
* Test that impossibly high 'page' query should error.
* Tests that impossibly high 'page' query should error.
*
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_invalid_max_pages_should_error
*
* @ticket 58524
*/
Expand All @@ -525,7 +541,9 @@ public function test_get_items_invalid_max_pages_should_error() {
}

/**
* Test that the default query should fetch all revisions.
* Tests that the default query should fetch all revisions.
*
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_default_query_should_fetch_all_revisons
*
* @ticket 58524
*/
Expand All @@ -534,14 +552,16 @@ public function test_get_items_default_query_should_fetch_all_revisons() {

$expected_count = $this->total_revisions;

$request = new WP_REST_Request( 'GET', '/wp/v2/global-styles/' . self::$global_styles_id . '/revisions' );
$request = new WP_REST_Request( 'GET', '/wp/v2/global-styles/' . self::$global_styles_id . '/revisions' );
$response = rest_get_server()->dispatch( $request );
$this->assertCount( $expected_count, $response->get_data() );
}


/**
* Test that 'offset' query shouldn't work without 'per_page' (fallback -1).
* 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
*/
Expand All @@ -558,7 +578,9 @@ public function test_get_items_offset_should_not_work_without_per_page() {
}

/**
* Test that 'offset' query should work with 'per_page'.
* Tests that 'offset' query should work with 'per_page'.
*
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_offset_should_work_with_per_page
*
* @ticket 58524
*/
Expand All @@ -581,7 +603,9 @@ public function test_get_items_offset_should_work_with_per_page() {
}

/**
* Test that 'offset' query should take priority over 'page'.
* Tests that 'offset' query should take priority over 'page'.
*
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_offset_should_take_priority_over_page
*
* @ticket 58524
*/
Expand All @@ -606,7 +630,9 @@ public function test_get_items_offset_should_take_priority_over_page() {
}

/**
* Test that 'offset' query, as the total revisions count, should return empty data.
* Tests that 'offset' query, as the total revisions count, should return empty data.
*
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_total_revisions_offset_should_return_empty_data
*
* @ticket 58524
*/
Expand All @@ -630,7 +656,9 @@ public function test_get_items_total_revisions_offset_should_return_empty_data()
}

/**
* Test that out of bound 'offset' query should error.
* Tests that out of bound 'offset' query should error.
*
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_out_of_bound_offset_should_error
*
* @ticket 58524
*/
Expand All @@ -654,7 +682,9 @@ public function test_get_items_out_of_bound_offset_should_error() {
}

/**
* Test that impossible high number for 'offset' query should error.
* Tests that impossible high number for 'offset' query should error.
*
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_impossible_high_number_offset_should_error
*
* @ticket 58524
*/
Expand All @@ -678,7 +708,9 @@ public function test_get_items_impossible_high_number_offset_should_error() {
}

/**
* Test that invalid 'offset' query should error.
* Tests that invalid 'offset' query should error.
*
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_invalid_offset_should_error
*
* @ticket 58524
*/
Expand All @@ -702,9 +734,11 @@ public function test_get_items_invalid_offset_should_error() {
}

/**
* Test that out of bounds 'page' query should not error when offset is provided,
* Tests that out of bounds 'page' query should not error when offset is provided,
* because it takes precedence.
*
* Duplicate of WP_Test_REST_Revisions_Controller::test_get_items_out_of_bounds_page_should_not_error_if_offset
*
* @ticket 58524
*/
public function test_get_items_out_of_bounds_page_should_not_error_if_offset() {
Expand Down

0 comments on commit de82ac9

Please sign in to comment.