Download the PHP package holgerk/guzzle-replay without Composer
On this page you can find all versions of the php package holgerk/guzzle-replay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download holgerk/guzzle-replay
More information about holgerk/guzzle-replay
Files in holgerk/guzzle-replay
Package guzzle-replay
Short Description A replay middleware for easier testing guzzle clients
License MIT
Informations about the package guzzle-replay
guzzle-replay middleware
Record guzzle requests and have them replayed during next runs. This helps creating tests for http api clients.
Install
Usage
Example
SimpleApiClient.php
SimpleApiClientTest.php
The following file is generated on first recording and updated on following recordings.
(for this you need to create the middleware with record mode: GuzzleReplay::create(GuzzleReplay::MODE_RECORD))
It contains all responses and requests that happen during the recording.
The name of the file is composed of test class name, test method name and the suffix: "_guzzleRecording.php".
If you don't like to have the recordings in separate files you can opt-out (see: Recording to method and not to a file)
SimpleApiClientTest_testGetUuid_guzzleRecording.php
Errors for unexpected requests
Output
Usage with Laravel Http Facade
Recording to method and not to a file
globally (for all tests)
locally (within one test)
Masking sensistive data
Usage with dataProviders
Best practices
- Use recordings to test every public method of your api client, buttests of your api client consumer you should use a mocked version of your api client. Otherwise you pollute your tests with redundant recordings, which require you todo many rerecordings, when you change the implementation of one of your api clients methods.
FAQ
- Why not just mock the guzzle client? Yes, this it is also an option. But if you want to ensure that your api client does not haved changed the exact http invocation, which in fact invalidates your fixtured response, one would need alot of verification boilerplate. Also it is teddious to fixture the exact response.
License
The MIT License (MIT). Please see License File for more information.
All versions of guzzle-replay with dependencies
sebastian/diff Version ^5||^6||^7
symfony/var-exporter Version ^5||^6||^7