-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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: add /revisions endpoint for global styles #4606
Rest API: add /revisions endpoint for global styles #4606
Conversation
268d816
to
82b6ddd
Compare
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Show resolved
Hide resolved
tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php
Show resolved
Hide resolved
ef8ab8a
to
40f7e65
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ramonjd, Can you add ticket number in unit tests?
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
* @doesNotPerformAssertions | ||
*/ | ||
public function test_context_param() { | ||
// Controller does not use get_context_param(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The controller does have context
set, so this should get tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that.
I was looking at how other tests implement test_context_param()
(example), and they're testing the data in $data['endpoints']
after an OPTIONS
call.
This controller doesn't have any other endpoint, e.g., WP_REST_Server::CREATABLE
and so I'm not sure how to test it. $data['endpoints']
doesn't have any testable data. Any tips?
I'll add another get_items
test to check that the correct fields are returned however.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a test test_get_item_embed_context
to check the difference when sending context as an arg in the GET request
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of nit picks, really.
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
92207a8
to
de82ac9
Compare
Thank @TimothyBJacobs @spacedmonkey and @peterwilsoncc for helping me make this patch better. I think I've addressed all of the feedback, (except for the context test) at least I think so. Please let me know where it can be improved. |
d97362a
to
41a765e
Compare
src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Show resolved
Hide resolved
Spacing between comments
- Introducing pagination - Updating tests
reformatting functions in test
Was a mistake
…or both of them are set.
1ec3540
to
f9bb652
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits but otherwise looks good.
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks good. The unit tests could do with @covers
.
Formatting and test annotations to include @Covers
The following Global Revisions UI was added to Gutenberg in:
To support this, an endpoint (/wp/v2/global-styles/revisions) that returns revisions for the global styles custom post was added and updated in:
This PR adds the endpoint to Core and adds tests.
Trac ticket: https://core.trac.wordpress.org/ticket/58524
Testing
To test the endpoint in the site editor, fire up this branch and head over to the site editor.
In your browser's console, switch to the network tab and run the following :
npm run test:php -- --filter WP_REST_Global_Styles_Revisions_Controller_Test
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.