-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
test for wp_maybe_load_widgets #3682
base: trunk
Are you sure you want to change the base?
Conversation
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 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. 🙂
* @group functions.php | ||
* | ||
* @covers ::wp_maybe_load_widgets | ||
*/# |
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.
*/# | |
*/ |
There was just a stray #
here
* @ticket 57201 | ||
*/ | ||
public function test_wp_maybe_load_widgets() { | ||
$this->assertFalse( class_exists( 'WP_Nav_Menu_Widget' ) ); |
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 thoughts:
- Test methods with multiple assertions should have a
message
parameter to explain what went wrong.
For similar assertions (i.e. multiple assertion of class_exists()
), the message can be:
WP_Nav_Menu_Widget
should not exist beforedoing something
.WP_Nav_Menu_Widget
should not exist afterdoing something
.WP_Nav_Menu_Widget
should 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 themessage
parameter)
Trac ticket: https://core.trac.wordpress.org/ticket/57201