-
Notifications
You must be signed in to change notification settings - Fork 154
Can I please have Invocation::setParameters() #390
Comments
Can you elaborate why what you need is no longer possible? |
Ok in short I need to remove one argument from the invocation. That's no more possible as there's no public API to do that. In v4 there was the public $parameters field. Now it's private and there's only a getParameters() on the interface. That's the technical explanation. Now about my use case: That library I'm maintaining is about mocking functions with the PHPUnit API. It was a long way to get this right for every edgne case (references, varargs and optional parameters) and one step on that way was detecting arguments with default values and removing them from the invocation. I think you should know how hairy this code generation can be from your own PHPUnit\Framework\MockObject\Generator. I see that you rely on Reflection::getDefaultValue(). I can't do that, so I use a marker argument and would simply remove that. I'm not 100% sure why I can't rely on getDefaultValue(). AFAIR it was about builtin functions which don't give that value away with reflection and don't have null as default value. |
PHPUnit-6.5 did change the signature of TestCase::getMockBuilder() by returning an object from phpunit-mock-object-5 instead of phpunit-mock-object-4. This broke this library: PHP Fatal error: Interface 'PHPUnit_Framework_MockObject_Matcher_Invocation' not found in /.../vendor/php-mock/php-mock-phpunit/classes/DefaultArgumentRemover.php on line 15 This commit adds a <phpunit-6.5 constraint to fix the current release. PHPUnit-6.5 is currently not supported by this library. I wait for sebastianbergmann/phpunit#2893 to decide how to support PHPUnit-6.5. See also: #21 See also: sebastianbergmann/phpunit#2893
It was wrong that
Are you absolutely sure that you cannot achieve what you need without manipulating |
@malkusch Do you have any feedback for me? |
No feedback, closing. |
Hi
I have a library which extents phpunit to mock PHP functions. This library has to remove a parameter from an invocation. This could be easily done in phpunit-mock-objects-4, but in v5 there's no public interface for that.
Could I kindly ask to add PHPUnit\Framework\MockObject\Invocation::setParameters(array)? I would happily provide a PR.
The text was updated successfully, but these errors were encountered: