The HTTP Fixtures package for Laravel generates fake JSON responses for external API calls in tests using Laravel's Http::fake()
. It simplifies creating mock responses by integrating with FakerPHP to generate realistic test data.
Generating fake HTTP responses can be tedious, and this package makes it easy by creating a fixture from a real HTTP request in your test:
The above code will create a fixture in tests/Fixtures
, and the underlying data is defined using Faker in a fixture class you can reuse. You can also generate fixtures from a JSON file or via an Artisan command:
Main Features
- Record fixture classes from live HTTP requests
- Create a fixture from a JSON file
- Create a new fixture via the package's Artisan command
- Control fixture output as JSON, XML, or an array
- Override specific keys using array dot notation
- And more...