Closed andresayej closed 4 years ago
To change the client in your test, I guess you are talking about functional tests , you can extend base class and override ‘getClient()’ method. No needs to modify constructor to do that.
Moreover, you can write plugins to guzzle, and attach them to client (it can help to solve your issue)
This PR introduces a way to swap the guzzle client.
This can be particularly useful if, for example, a dev wants to use a different class that extends the
GuzzleHttp\Client
.My personal use-case in my Laravel application was that I wanted to swap the client when running Tests with a custom class that extends the
GuzzleHttp\Client
and has some special snapshotting functionality in it.Example from the codebase located in the
app/Providers/AppServiceProvider.php
This is NOT a breaking change because the newly introduced
__construct
argument has a default fallback value -null
if the client is not provided wheniTunesValidator
is instantiated.