jeudi 16 janvier 2020

How to test a service that interacts with a 3rd party API?

I have the following service which I want to test:

namespace App\Service;

class ApiManager
{
   public function getProjects()
   {
      // HTTP request for fetching external projects here
   }
}

Of course I don't want to test with real data from the API. How can I mock the data that gets returned from the HTTP request in getProjects?

Aucun commentaire:

Enregistrer un commentaire