Open jasonmccreary opened 4 years ago
@adamwathan, I did my best to adhere to the contribution guidelines.
A few areas I think could be touched up:
Zttp::$expectations
propertyZttp
and PendingZttpRequest
handler concept.Otherwise, I think this does well to preserve the encapsulation of Guzzle and doesn't hijack the request lifecycle in any way (runs as the last middleware), while achieving the API you outlined.
cc/ @taylorotwell
Need this, it's probably a convenient way to implement a cache system by ourselves.
This adds a
Zttp::stub
method which accepts a callback where you may perform logic to return stubbed responses in your tests. This way your code doesn't actually send a request across the network.It introduces a new
ZttpResponseStub
to quickly create responses that will be treated just like aZttpResponse
in your code, while remaining decoupled from the underlying Guzzle classes.Before, you might have mocked
Zttp
directly or through a service object wrapper. Now you may simply call:This also introduces a
Zttp::clearStubs
method to remove any previous stubs.