mockery->shouldReceive() passing when it shouldnt?
Mockery is by default a stubbing library, not a mocking one (which is confusing because of its name).
That means that ->shouldReceive(...)
by default is "zero or more times". When using ->once()
, you say it should be called zero or one time, but not more. This means it'll always pass.
When you want to assert that it is called once, you can use ->atLeast()->times(1)
(one or more times) or ->times(1)
(exactly one time)