Summer Sale! All accounts are 50% off this week.

sh1r3f's avatar

Can I mock a facade without passing parameters?

I need to mock a facade while testing and I found in laravel documentation that I can do it like this

        Cache::shouldReceive('get')
                    ->once()
                    ->with('key')
                    ->andReturn('value');

The idea is I don't want to pass with('key') for some reason. can I make it work without giving it the parameters to be passed?

0 likes
1 reply
sh1r3f's avatar
sh1r3f
OP
Best Answer
Level 1

Solved by using withAnyArgs() instead of with()

Please or to participate in this conversation.