I'm mocking a UserRepository class using prophecy to ensure that when a POST
request to /user
is sent, that the create()
method on UserRepository is fired.
$repository = $this->prophesize(UserRepository::class);
$repository->create()->shouldBeCalled()
The only problem is that the create()
method sends Request data as an argument to the repository for some serious tweaking of the inputs before doing anything. How do I mock the create()
call without telling prophecy what the arguments will be?
Or is this just really bad practice on my end and the Request data should never be passed to the repository?
use Prophecy\Argument;
$repository->create(Argument::cetera())->shouldBeCalled()
any()
matches any single value where cetera
matches all values to the rest of the signature.
use Prophecy\Argument;
$repository->create(Argument::any())->shouldBeCalled()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With