Allow mocking same _actions_ with different arguments
Closed this issue · 2 comments
dnaber-de commented
Hello, it's me again. Do you remember our conversation here? I found some time to search for the problem and it looks like Monkey::functions()
does work like expected but Monkey::action()->expectFired()
does not.
In fact I would expect the same behavior described in #5.
I wrote a test in 83c80e7, following the FunctionsTest::testSameFunctionDifferentArguments()
, that shows the problem:
There was 1 error:
1) Brain\Monkey\Tests\WP\ActionFireTest::testFiredSameActionDifferentArguments
Mockery\Exception\NoMatchingExpectationException: No matching handler found for Mockery_14__do_double_action::do_action_double_action("arg_1"). Either the method was unexpected or its arguments matched no expected argument list for this method
/var/www/projects/php/brain-monkey/vendor/mockery/mockery/library/Mockery/ExpectationDirector.php:93
/var/www/projects/php/brain-monkey/src/Monkey/WP/Hooks.php:249
/var/www/projects/php/brain-monkey/src/Monkey/WP/Actions.php:93
/var/www/projects/php/brain-monkey/src/Monkey/WP/Hooks.php:110
/var/www/projects/php/brain-monkey/inc/wp-functions.php:43
/var/www/projects/php/brain-monkey/tests/unit/WP/ActionFireTest.php:181
I'm not completely in to Mockery/Monkey to say what's the problem, but I'll take some time to figure it out.
gmazzap commented
Thanks again @dnaber-de !
This is finally fixed with 9ef08dc :)
To be sure, I added tests for
- multiple actions added more times with different args
- multiple actions fired more times with different args
- multiple filters added more times with different args
- multiple filters fired more times with different args
I am going to merge and release v1.3.2
.
Thanks again for reporting!
dnaber-de commented
Perfect!