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

Create Mock Objects for PHPUnit testing Custom Integrations #91

Closed
bradberger opened this issue Jul 1, 2014 · 6 comments
Closed

Create Mock Objects for PHPUnit testing Custom Integrations #91

bradberger opened this issue Jul 1, 2014 · 6 comments

Comments

@bradberger
Copy link

I'm working on a site that requires a Stripe integration. It would be great if I could mock the Stripe API's when running the site's unit tests, as it's a lot, lot slower to connect to Stripe's servers when running the tests.

It would also be great because the mock api could return a specific set of predetermined values for given api calls, which would help test any custom integration with the Stripe API.

Is that a possibility?

@bkrausz
Copy link
Contributor

bkrausz commented Jul 1, 2014

Generally we don't provide mocks for any of our bindings, because our API is evolving and it would become one more thing to keep up to date, especially given that responses can change based on the API version you're using.

I think it would be much better to stub out network requests/responses against our test API and record/replay what you receive back from our servers. That way it becomes easy to re-record when you bump versions.

Unfortunately, since we use cURL directly, we don't provide a good way to stub out the network layer either. If you think that would solve your mocking concerns I'm happy to build in a way to replace cURL with a mocked version.

We're also thinking about ways to make mocking our bindings easier by offering a non-static version, though that won't happen in the immediate future as it's a pretty significant change.

@bkrausz
Copy link
Contributor

bkrausz commented Jul 11, 2014

See #97

@bkrausz bkrausz closed this as completed Jul 11, 2014
@bkuhl
Copy link

bkuhl commented Jun 5, 2018

In a world of increasing testability and better testing tools, this would be great.

@seyfer
Copy link

seyfer commented Feb 6, 2019

The same issue. Mocking all these Stripe_* classes with the data structure is not easy.

@bkuhl
Copy link

bkuhl commented Feb 6, 2019

I will add that we do understand that this issue is very old and so is the SDK.

I ended up wrapping the SDK with my own classes to make things easier.

@remi-stripe
Copy link
Contributor

@bkuhl @seyfer Have you looked into our mock library stripe-mock? This should work for you as this is what our own test suite uses in the library today.

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

5 participants