easy-http / mock-builder
A fluid interface to build HTTP mocks with an expressive syntax
Installs: 17 427
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.4|^8.0
- ext-json: *
- guzzlehttp/guzzle: ^6.0|^7.0
- guzzlehttp/promises: ^1.4|^2.0
Requires (Dev)
- easy-http/guzzle-layer: ^1.0
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.5
README
π Mock HTTP services
Mock builder
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.
π§ Installation
Use following command to install this library:
composer require easy-http/mock-builder
π‘ Usage
Creating a simple Mock for Guzzle
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.