phplaraveltestingmockingprophecy

PHPUnit prophesize a method without exact arguments


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?


Solution

  • use Prophecy\Argument;
    
    $repository->create(Argument::any())->shouldBeCalled()