Tests: Assert themes REST API has no context param - #13859
shail-mehta wants to merge 3 commits into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| foreach ( $data['endpoints'] as $endpoint ) { | ||
| $this->assertArrayNotHasKey( 'context', $endpoint['args'] ); | ||
| } |
There was a problem hiding this comment.
Thanks for replacing the empty stub with real assertions!
A small suggestion: the other test_context_param() tests in the REST API suite index the first endpoint directly rather than looping, e.g. $data['endpoints'][0]['args']['context'] in the taxonomies, pages and comments controller tests. Both themes routes register only a single READABLE endpoint, so the loop always runs once anyway.
Using [0] would match that convention. It also makes the test fail loudly if the endpoint is ever missing. With the loop, an empty endpoints array would make no assertions and the test would still pass.
| foreach ( $data['endpoints'] as $endpoint ) { | |
| $this->assertArrayNotHasKey( 'context', $endpoint['args'] ); | |
| } | |
| $this->assertArrayNotHasKey( 'context', $data['endpoints'][0]['args'] ); |
| foreach ( $data['endpoints'] as $endpoint ) { | ||
| $this->assertArrayNotHasKey( 'context', $endpoint['args'] ); | ||
| } |
There was a problem hiding this comment.
Same suggestion as on the collection loop, for the single-theme route:
| foreach ( $data['endpoints'] as $endpoint ) { | |
| $this->assertArrayNotHasKey( 'context', $endpoint['args'] ); | |
| } | |
| $this->assertArrayNotHasKey( 'context', $data['endpoints'][0]['args'] ); |
Verify that OPTIONS responses for both the themes collection and single-theme routes omit the context argument. Developed in: #13859 Props shailu25, mukesh27. See #40538. git-svn-id: https://develop.svn.wordpress.org/trunk@64023 602fd350-edb4-49c9-b593-d223f7449a82
|
PR #13859 landed in https://core.trac.wordpress.org/changeset/64023 |
Verify that OPTIONS responses for both the themes collection and single-theme routes omit the context argument. Developed in: WordPress/wordpress-develop#13859 Props shailu25, mukesh27. See #40538. Built from https://develop.svn.wordpress.org/trunk@64023 git-svn-id: http://core.svn.wordpress.org/trunk@63183 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Trac ticket: #40538
What
Replaces the empty
@doesNotPerformAssertionsstub fortest_context_param()in the themes REST API tests with real assertions.Why
Per #40538, remaining read-side empty stubs should become real assertions.
rest-themes-controller.phphas one claimable read-side case:test_context_param(). Write-side stubs are left alone pending #66073.How
In
WP_Test_REST_Themes_Controller::test_context_param():OPTIONSto/wp/v2/themes(collection) and/wp/v2/themes/{stylesheet}(single)200contextargTesting instructions
node ./tools/local-env/scripts/docker.js run --rm php ./vendor/bin/phpunit --filter 'WP_Test_REST_Themes_Controller::test_context_param'Use of AI Tools