-
Notifications
You must be signed in to change notification settings - Fork 30
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
Remove filter test example? #41
Comments
Hi @dingo-d let's go in order. Test
|
First of all, thanks for the detailed answer :) I'm a bit of a newbie when it comes to testing, so I'm not all clear on some things. Your answer helped a lot. I was suspecting I cannot test the anonymous functions but just wanted to be clear. I will add integration tests after I finish writing the unit tests because I'll need to mock a lot of things in the integration tests later on (I'm basically using WP for backend only so there are a lot of things to test). Once I add the integration tests for the headers, these lines should become green, no? I was even thinking of rewriting the function with the headers as a separate private function and adding it to the As for unit testing headers, I think that would have to be mocked (I might be wrong), but then the test wouldn't make much sense, as you mentioned. I'll just explain to the client that some things cannot be fully tested, but if the front end app works (which it does) it's basically a test so it's all ok :) Thanks again for the great answer. |
I'm going through the documentation, and I can see examples for tests that use
add_filter
andadd_action
, but I don't see any mention of testingremove_filter/action
.So am I right in assuming this is the right way to test for
remove_filter
in a method?Test:
The
InitTestCase
looks like thisThe test passes, so I guess this is ok? Also I'm testing the added filter by adding
and this also passes, but I don't see a green bar over that line in my code coverage report.
EDIT
I added
To my test function and still my second filter isn't covered. Also, how do you test anonymous functions?
The text was updated successfully, but these errors were encountered: