1

I've written new repository using omnipay for x payment gateway. I've successfully written test cases for repository itself. Now the problem is i am using this repository in my code and it's also working fine.

e.g.

$gateway->purchase($parametersArray)->send(); 
$response->isSuccessful();

Now i want to write test cases for the above code by mock/any method.

Kapil Verma
  • 178
  • 3
  • 17

1 Answers1

0

Probably the thing to do is to pick up an existing omnipay repository and see how they do their test cases.

For example, this repository has test cases for all of the PayPal REST methods:

https://github.com/thephpleague/omnipay-paypal

See under tests/Message and tests/Mock

delatbabel
  • 3,601
  • 24
  • 29
  • Thanks for the answer. But i already written test cases and mock for the repository. Now i want to write test cases of integration code where i am using this repository. Hope it clears. – Kapil Verma Aug 03 '17 at 06:22
  • OK that's more of a generic question like "how do I write test cases for my code?". It depends a lot on what your code looks like, what framework you use, etc. Does your framework have a testing harness? Are you using a BDD testing harness like Behat or Codeception? I would recommend you do some general reading on PHP test frameworks and come back with a more specific question. Generally, though, you can mock any of the omnipay classes and return whatever responses you want using the Mockery harness. – delatbabel Aug 10 '17 at 01:37
  • 1
    I am using the phpunit and my code is written in Laravel. I don't think it's depends on code. Many of us are using omnipay and integrating with any framework or cms, but process is same for all frameworks using omnipay . – Kapil Verma Aug 10 '17 at 12:22