Add convenience `::expectFilterRemoved()` `::expectActionRemoved()` Fix #157
Summary
As said in #157:
WP_Mock provides useful helpers for
expectFilterAddedandexpectFilterNotAdded, and [their] companion actions. However, we have no canonical way of checkingremove_actionnorremove_filtercalls.
See: remove_filter().
Closes: #157
Details
It's really just a convenience function on top of WP_Mock::userFunction().
public static function expectFilterRemoved(string $filter, $callback, $priority = null) : void
{
self::userFunction(
'remove_filter'
array(
'args' => array_filter(func_get_args()),
'times' => 1,
)
);
}
We're using array_filter() there to handle the optional use of $priority in remove_filter().
::expectFilterNotRemoved() is the same with 'times' => 0.
Contributor checklist
- [x] I agree to follow this project's Code of Conduct.
- [x] I have updated the documentation accordingly
- [x] I have added tests to cover changes introduced by this pull request
- [x] All new and existing tests pass
Testing
Reviewer checklist
- [ ] Code changes review
- [ ] Documentation changes review
- [ ] Unit tests pass
- [ ] Static analysis passes
coverage: 64.889% (-1.6%) from 66.445% when pulling 67017782c351c0fceb9d74c53545cb424e1566a1 on BrianHenryIE:add/remove-action-remove-filter into 48b7f22934a4351e45e336f09263ee27fc9ddcbe on 10up:trunk.
coverage: 67.522% (+1.1%) from 66.445% when pulling 7d01fcb251bd6be87396602422d13a810ec58b4b on BrianHenryIE:add/remove-action-remove-filter into 48b7f22934a4351e45e336f09263ee27fc9ddcbe on 10up:trunk.
coverage: 67.651% (+1.2%) from 66.445% when pulling cd4cff50eca56e67491aafbd772f0e7e988bb388 on BrianHenryIE:add/remove-action-remove-filter into 48b7f22934a4351e45e336f09263ee27fc9ddcbe on 10up:trunk.
coverage: 67.651% (+1.2%) from 66.445% when pulling f56c5575258aaa920acd18b87986f4011af1a04e on BrianHenryIE:add/remove-action-remove-filter into 48b7f22934a4351e45e336f09263ee27fc9ddcbe on 10up:trunk.