test for wp_maybe_load_widgets#3682
Conversation
costdev
left a comment
There was a problem hiding this comment.
Thanks for the PR @pbearne and for working to implement standards early to save time in reviewing / implementing review feedback! Much appreciated and look forward to seeing that in future PRs!
I've left some thoughts below which should help with an unmet standard (message parameter) and test stability. 🙂
| * @ticket 57201 | ||
| */ | ||
| public function test_wp_maybe_load_widgets() { | ||
| $this->assertFalse( class_exists( 'WP_Nav_Menu_Widget' ) ); |
There was a problem hiding this comment.
A couple of thoughts:
- Test methods with multiple assertions should have a
messageparameter to explain what went wrong.
For similar assertions (i.e. multiple assertion of class_exists()), the message can be:
WP_Nav_Menu_Widgetshould not exist beforedoing something.WP_Nav_Menu_Widgetshould not exist afterdoing something.WP_Nav_Menu_Widgetshould exist afterdoing something.
- It may be best to split this into two test methods:
test_wp_maybe_load_widgets_should_respect_falsy_load_default_widgets_filter()- Use a data provider with falsy values to send to the filter hook via static closure, thenassertFalse()forclass_exists()andhas_action().test_wp_maybe_load_widgets_should_load_widgets()-assertFalse()forclass_exists()andhas_action(), then callwp_maybe_load_widgets(), thenassertTrue()onclass_exists()andhas_action()(all assertions should have themessageparameter)
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @pbearne@git.wordpress.org. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
…est_wp_maybe_load_widgets`.
…o 57201_wp_maybe_load_widgets
Trac ticket: https://core.trac.wordpress.org/ticket/57201