Mock Builder Setup

Setting up the Mock builder is a straightforward process. You have to set up your expectations and the returned response when these expectations are met. In order to do that you should use the MockBuilder and HttpMockclasses as follows.

use EasyHttp\MockBuilder\HttpMock;
use EasyHttp\MockBuilder\MockBuilder;

$builder = new MockBuilder();
        // ... define all expectations
        // ... define body, status code, headers, ...

$mock = new HttpMock($builder);

The next step is to inject this mock to the particular http client you're using.

Guzzle Client

If you're using Guzzle client you can use the HandlerStack class to inject a mock.

use GuzzleHttp\HandlerStack;
use GuzzleHttp\Client;

$client = new Client(['handler' => HandlerStack::create($mock)]);

Easy Http client

If you're using any of the Easy Http layers you could use the withHandler method of EasyClientContract.