MyTestCasethat is assumed very similar to the one coded in the WordPress / Setup docs section.
has_filter()that, just like real WordPress functions can be used to test if some hook (action or filter) has been added, and also verify the arguments.
$thisoutside of the class.
has_filterallow to check this cases with a very intuitive syntax:
->and the method name followed by parenthesis.
::and the method name followed by parenthesis, e.g.
__invoke()method) can be identified by the class name followed by parenthesis, e.g.
has_filter()if a specific closure has been added to an hook.
staticclosures. Following closure:
remove_filtercan make impossible to test some code using
has_filter, because hooks are actually removed.
with(), validates hook arguments, not function arguments, it means what is passed to
add_filter()excluding hook name itself.
andReturnmethod that allows to force an expectation to return a given value.
expectAdded()method works with Mockery expectations, you may be tempted to use it... if you do that an exception will be thrown.
add_filterthat had been in contrast with real WordPress code, with disastrous effects on tests.