Closed debasishrowlo closed 3 years ago
For WordPress, I installed it as a fixture in my tests. You can shell out from php to hit wpcli to migrate that database. I added a MU plugin to the be able to direct access the information I needed for assertions.
For other services, if it's free and has side effects you can work with, make a testing account.
Now I'm trying work with OFX (banking). Still not totally sure how I want to approach that. Real money can be lost if you screw up.
I had the same with discord. In the end I've just created another "bot" and a custom server for testing since it does not cost anything on discord.
That's why I like services like stripe and braintree so much..
Use PHP VCR! https://github.com/php-vcr/php-vcr
Sure, this would work but you wouldn't have the 100% confidence that it will really work. In the end what I did was:
I had the same question as I was watching module 9. @adamwathan Can you comment here? We're running into a situation where we have an API we need to integrate with that does not have any concept of test/sandbox tokens - would you fall back to mocking in that scenario or use a different approach?
I'm assuming the answer lies somewhere along the lines of: https://adamwathan.me/2016/01/25/writing-your-own-test-doubles/ :)
Sorry for the delay — in that case I would still just test my app code against a fake of my own API wrapper for the service. The only real difference is that you can't actually integration test your wrapper, so you just have to live with some risk there. I'd keep the wrapper as simple and unclever as possible so that it rarely needs to be changed and any time that code does change I'd test the crap out of it manually.
How do we integration test external APIs which do not provide Test mode like Stripe does (e.g - Wordpress or Skype API)?