Skip to content

Conversation

@costdev
Copy link
Contributor

@costdev costdev commented Apr 30, 2022

This PR revises the datasets from PR 2201 for accurate testing.

Trac ticket: https://core.trac.wordpress.org/ticket/54870

@costdev costdev force-pushed the wp_nonce_url-unit-tests branch 2 times, most recently from 3b0f573 to e99d99c Compare April 30, 2022 05:16
@costdev costdev marked this pull request as ready for review April 30, 2022 05:54
@costdev costdev force-pushed the wp_nonce_url-unit-tests branch 2 times, most recently from 6620c85 to c949408 Compare April 30, 2022 05:57
Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some review

@costdev costdev force-pushed the wp_nonce_url-unit-tests branch from c949408 to 5be5a43 Compare September 22, 2022 16:19
* @param string $actionurl URL to add nonce action.
*/
public function test_should_handle_existing_query_args( $actionurl ) {
$actionurl = preg_replace( '/&(?!amp;)/', '&', $actionurl );
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@costdev costdev force-pushed the wp_nonce_url-unit-tests branch from 5be5a43 to da9f3a4 Compare October 6, 2022 22:24
@costdev costdev requested a review from peterwilsoncc October 6, 2022 22:25
Copy link
Contributor

@peterwilsoncc peterwilsoncc left a 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.

costdev added 2 commits October 7, 2022 03:31
Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dandy 🌻

Thank you!

@peterwilsoncc
Copy link
Contributor

Committed in https://core.trac.wordpress.org/changeset/54407 / 426d20a

@costdev costdev deleted the wp_nonce_url-unit-tests branch October 7, 2022 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants