gsaulmon/guzzlerecorder

Records and plays back guzzle responses

2.3 2022-02-15 16:10 UTC

This package is not auto-updated.

Last update: 2024-12-18 05:01:55 UTC


README

This is an event listener plugin for Guzzle 4/5 aimed at setting up tests for complex responses a bit quicker.

Usage

Attach an instance of the recorder to any Guzzle Client

$client = new GuzzleHttp\Client();

$watcher = new Gsaulmon\GuzzleRecorder\GuzzleRecorder(__DIR__ . '/my_test_responses');
$client->getEmitter()->attach($watcher);

Then run your tests. The recorder will grab and store all Guzzle responses in the "my_test_responses" folder. All subsequent runs of the tests will have the Guzzle requests intercepted and will be injected with the stored response.

The responses store will be the full actual response. Make sure to edit out any information you may not want to share.