🚀 Mock HTTP services
A fluid interface to build HTTP mocks with an expressive syntax. You can use this library to build mocks for Guzzle, Symfony and other HTTP Clients.
This library supports the following versions of Guzzle Http Client.
Use following command to install this library:
composer require easy-http/mock-builder
use EasyHttp\MockBuilder\HttpMock;
use EasyHttp\MockBuilder\MockBuilder;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Client;
$builder = new MockBuilder();
$builder
->when()
->pathIs('/v1/products')
->methodIs('POST')
->then()
->body('bar');
$mock = new HttpMock($builder);
$client = new Client(['handler' => HandlerStack::create($mock)]);
$client
->post('/v1/products')
->getBody()
->getContents(); // bar
📚 Check out the Documentation to learn how to use this library.