vendredi 12 avril 2019

Is there a way of mocking an API request by default if you are in a test environment using Laravel?

I have an API method that is called by clicking a buttom in a form and inside that API method there is a request to another API of another project using guzzle. That works fine.

My problem is I'm doing behat tests and I want to test my API method, but I need to mock the request to the external API (because I don't need to test it). Is there any way Laravel detects if I am in a test environment and mock the request and if I'm in a normal environment leave it without mock?

Aucun commentaire:

Enregistrer un commentaire