Skip to content

#2153 add a test helper for auto-removing filters#2158

Merged
acobster merged 1 commit into2.x-user-factoriesfrom
2.x-temporary-hooks
Jan 9, 2020
Merged

#2153 add a test helper for auto-removing filters#2158
acobster merged 1 commit into2.x-user-factoriesfrom
2.x-temporary-hooks

Conversation

@acobster
Copy link
Copy Markdown
Collaborator

@acobster acobster commented Jan 8, 2020

Ticket: #2153

Issue

See #2153

Solution

Add a test helper for adding a self-removing filter. I didn't end up implementing the same for add_action since there are very few calls in the tests at this time. We can always add that in the future if desired.

Impact

Affects tests only, and allows for cleanly refactoring existing tests. Pure refactor; doesn't change production or test functionality.

Usage Changes

None.

Considerations

Let's just switch direct add_filter() calls over as we find time.

Testing

Why, yes!

@acobster acobster added the 2.0 label Jan 8, 2020
@acobster acobster requested a review from jarednova January 8, 2020 04:43
Copy link
Copy Markdown
Member

@gchtr gchtr left a comment

Choose a reason for hiding this comment

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

Ooh, that looks really good! 🚀

I’ve run into so many issues in the past because I set up filters in tests that I didn’t remove properly afterwards. I was fighting a lot with how to set up temporary filters until I’ve realized that I can assign a closure function to a variable.

Having a helper function that simplifies this even more will surely help a lot 👍.

@acobster acobster merged commit fd7594f into 2.x-user-factories Jan 9, 2020
@nlemoine nlemoine deleted the 2.x-temporary-hooks branch June 23, 2022 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants