-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add tests for wp_nonce_url().
#2653
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
Conversation
3b0f573 to
e99d99c
Compare
6620c85 to
c949408
Compare
mukeshpanchal27
left a comment
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.
Left some review
c949408 to
5be5a43
Compare
| * @param string $actionurl URL to add nonce action. | ||
| */ | ||
| public function test_should_handle_existing_query_args( $actionurl ) { | ||
| $actionurl = preg_replace( '/&(?!amp;)/', '&', $actionurl ); |
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 looks a little like it is testing the code by running a copy-paste of the code.
I think i'd prefer an $expted to be passed so it's clear what is been tested.
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.
Not quite a copy-paste. It's taking a realistic URL from the data provider, and ensuring that it has &. In doing so, this verifies that str_replace() is called in wp_nonce_url() to convert & to &.
I'm happy to change the variable on Line 108 from $actionurl to $expected. The parameter however is named $actionurl to increase familiarity between the source function and the test method/datasets for easier testing, so I'd like to keep the parameter name as-is. Does that work for you?
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 was thinking more of using two params, $actionulr, $expected, to avoid surprises
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.
Hmm... Looking back over this test method and datasets, this PR needs more work to properly cover wp_nonce_url.
I'll ping you when I have this revision work done.
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.
@peterwilsoncc Ping!
5be5a43 to
da9f3a4
Compare
peterwilsoncc
left a comment
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.
LGTM, added a suggestion about a more precise assertion because I am the worst.
Literally testing how long a string is. Thanks, Peter.
peterwilsoncc
left a comment
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.
Dandy 🌻
Thank you!
|
Committed in https://core.trac.wordpress.org/changeset/54407 / 426d20a |
This PR revises the datasets from PR 2201 for accurate testing.
Trac ticket: https://core.trac.wordpress.org/ticket/54870