Search code examples
phpspec

Accepting all parameters in phpsepc2 mocks


How i can accept all parameters in function mock with #phpspec2?

for example i have code like this:

$em->persist($entity)->willReturn(true);

I don't want mock all possible parameters, it should accept every entity.


Solution

  • You can use Argument class and any method/function:

    use Prophecy\Argument;
    ...
    Argument::any()
    

    Here you can find more details about this.