#2153 add a test helper for auto-removing filters#2158
Merged
acobster merged 1 commit into2.x-user-factoriesfrom Jan 9, 2020
Merged
#2153 add a test helper for auto-removing filters#2158acobster merged 1 commit into2.x-user-factoriesfrom
acobster merged 1 commit into2.x-user-factoriesfrom
Conversation
gchtr
approved these changes
Jan 8, 2020
Member
gchtr
left a comment
There was a problem hiding this comment.
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 👍.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_actionsince 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!