mercredi 30 septembre 2020

PHP unit test - How to fake a vendor Guzzle request

I'm trying to make a test that involves 2 services on PHP.

The internal logic of my service 'A' needs to send a message to service "B". I do not have B configured, so it will always respond with error on a testing environment, however, i don't need to know what 'B' does, i just need to know that after 'B' gave a 200 response, the callback on service 'A' saves some data on my DB.

The communication between services is handled by a private vendor package that uses Guzzle under the hood. The problem i found, is that i cannot seem to be able to use Guzzle Mock or STack without touching the vendor's source code right?

So, is the best solution creating a fake api that always responds 200 to my requests on the same ip:port of the real "B" service??

Thanks!

Aucun commentaire:

Enregistrer un commentaire