You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently WP_Mock needs a reference to an object instance for expectHookAdded to work. A common pattern where this is a problem is where the actions and filters are added during object construction.
The general advice has been to separate object construction and adding hooks. This is fine, but the solution to this is easy and is coherent with WP_Mock.
I tried adding the functionality into FuzzyObject but became uncertain of side-effects. It may be possible, and preferable. The current code is a straightforward proof of concept – I expect suggestions and alterations before any PR.
The text was updated successfully, but these errors were encountered:
Problem:
Currently WP_Mock needs a reference to an object instance for
expectHookAdded
to work. A common pattern where this is a problem is where the actions and filters are added during object construction.The problem is described in #8, #80, #93, #127, #143.
Solution:
Add a matcher like
WP_Mock::fuzzyObject()
–AnyInstance()
.Allowing:
This is basically the solution proposed in #12 .
I have this working in my own fork: Add AnyInstance matcher.
And can be tested with:
Describe alternatives you've considered
The general advice has been to separate object construction and adding hooks. This is fine, but the solution to this is easy and is coherent with WP_Mock.
I tried adding the functionality into
FuzzyObject
but became uncertain of side-effects. It may be possible, and preferable. The current code is a straightforward proof of concept – I expect suggestions and alterations before any PR.The text was updated successfully, but these errors were encountered: