jeudi 13 septembre 2018

How can I mock external API during testing in laravel 5?

I want to test an HTTP route in laravel. The action function of the URL calls a helper function, which calls an external API. How can I mock the external API call while testing?

public function actionFunction(){

     $helper = new HelperClassHelper();

     return Response::json($helper->getNames());

}

Here, the getNames() function makes an external API call. How do I mock it?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2NDPWO9
via IFTTT

Aucun commentaire:

Enregistrer un commentaire