thephpleague / omnipay

A framework agnostic, multi-gateway payment processing library for PHP 5.6+
http://omnipay.thephpleague.com/
MIT License
5.94k stars 927 forks source link

UnitTest help on few methods #89

Closed cvele closed 11 years ago

cvele commented 11 years ago

I'm working on adding CyberSource as payment provider (https://github.com/cvele/omnipay/tree/CyberSource) and would appriciate a bit of help on building unit tests for few methods: Refund, DeleteCard, UpdateCard.

Main problem I have there is that those methods require id to be passed to them and I don't have it.

Would like to avoid mocking responses.

Also, how do you handle api key situations for tests ?

amacneil commented 11 years ago

Have a look at how the unit tests for some of the other gateways are structured. Stripe is a good example:

https://github.com/adrianmacneil/omnipay/tree/master/tests/Omnipay/Stripe

Mocking responses is the only way, basically run some code locally and capture the successful and unsuccessful responses, then save them to text files and use them to write your tests.