Download the PHP package dbt/client-fake without Composer
On this page you can find all versions of the php package dbt/client-fake. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package client-fake
Client Fake for Laravel
This package provides an easy way to fake HTTP calls for services that requires Laravel's HTTP Client in testing contexts. If you're using the HTTP Facade, this package isn't for you.
Simply extend or directly construct the ClientFake
, register your fakes, then commit or invoke the result. When your service resolves the HTTP Client from the container, it will be resolved with the fakes applied only to that instance of the HTTP Client.
For instance if you have FooService
and BarService
, if you register a fake for BarService
, the fake only be applied to that service, and not to any others.
This is useful when you have one service that you want to fake, but not others.
Installation
You can install the package via composer:
Usage
You can use the ClientFake
class directly, or extend it and define method fakes of your own.
If you want to use the ClientFake
directly, you can do so like this (for example, in the body of your test):
Then you can resolve your service and use it as normal:
Catchall
By default, a catchall is added, which will return a 500 response for any endpoint that isn't faked. You can disable this:
Conditionally Enabling
You can conditionally enable and disable the fake by using the enable
method:
You can optionally add a callback that will be resolved from the container and executed when the boolean condition is false:
Options
You can use the ClientFakeOptions
object as-is, or define your own by implementing the ClientFakeOptionsInterface
.
Etc.
Please see CONTRIBUTING for details. The MIT License (MIT). Please see License File for more information.
All versions of client-fake with dependencies
fakerphp/faker Version ^1.21
illuminate/http Version ^8.0|^9.0|^10.0
guzzlehttp/guzzle Version ^7.2