-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to stub without overriding function #401
Comments
Relevant snippets:
|
you need to set - allow(MyClass::class)->toReceive("getString");
+ allow(MyClass::class)->toReceive("getString")->andReturn('the string'); |
Thanks @samsonasik, but this was just a minimal example to demonstrate that I can't stub a function without overriding it. I want to just spy on the function and assert that it was called, as the docs say is possible. |
I see, in that case, you need to use - allow(MyClass::class)->toReceive("getString");
+ expect(MyClass::class)->toReceive("getString"); |
Brilliant, that works. |
The online documentation states
But I can't quite get this to work as I expect, I've made a minimal reproduction repo here: d0x2f/kahlan-stub-repro.
To be clear, what I'm trying to do is spy on a function and check that it was called n times without changing the behaviour of the function.
Thanks for your help!
The text was updated successfully, but these errors were encountered: