Simplify report controller parameters #1826
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes proposed in this Pull Request:
Based on the discussion here, this PR cleans up the report controllers to make the code reusable and take advantage of the existing function WP_REST_Request::get_default_params
Detailed test instructions:
Unit testing is still not implemented for the Report Controllers (I started an attempt, but it's going to take a substantial effort to unit test these classes so I left it out for now).
The reports can be tested manually as outlined in PR #251, although this PR doesn't change the report data so we would only want to confirm that the parameter defaults still get mapped in the same way.
The easiest way to test that is to set a break point in

prepare_query_arguments
and confirm that the arguments are as expected:A GET request without query parameters can be sent to
https://domain.test/wp-json/wc/gla/ads/reports/programs
.Changelog entry