Skip to content
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

Why not mock the payment gateway? #32

Open
AdamEsterle opened this issue Feb 7, 2017 · 1 comment
Open

Why not mock the payment gateway? #32

AdamEsterle opened this issue Feb 7, 2017 · 1 comment

Comments

@AdamEsterle
Copy link
Collaborator

AdamEsterle commented Feb 7, 2017

I am new to fakes, but I think I am understanding them albeit slowly.
To me they feel a little too fake - for lack of a better word.

Instead of:
$this->assertEquals(9750, $this->paymentGateway->totalCharges());
Which then has to have code irrelevant to the rest of your app (storing the charges as an array and then summing them)

Why not use a mock on the real StripeGateway and just verify that "charge" was called with parameter 9750?

Any shedding of light on this situation (when to use a fake or a mock) would be greatly appreciated.

@adamwathan
Copy link
Collaborator

Hey Adam! I'm going try go make time tonight to answer this in more detail, but in the mean time here's a blog post I wrote a while back that goes into some of the benefits of fakes vs. mocks:

https://adamwathan.me/2016/01/25/writing-your-own-test-doubles/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants