Recording Requests
Setup
<?php
$mockClient = new MockClient([
GetForgeServerRequest::class => MockResponse::fixture('singleServer')
]);<?php
Saloon::fake([
GetForgeServerRequest::class => MockResponse::fixture('singleServer')
]);How does it work?
<?php
$mockClient = new MockClient([
GetForgeServerRequest::class => MockResponse::fixture('singleServer')
]);
// The initial request will check if a fixture called "singleServer"
// exists. Because it doesn't exist yet, the real request will be
// sent and the response will be recorded.
$request = new GetForgeServerRequest(12345);
$response = $request->send($mockClient);
// However, the next time the request is made, the fixture will
// exist, and Saloon will not make the request again.
$request = new GetForgeServerRequest(12345);
$response = $request->send($mockClient);<?php
Saloon::fake([
GetForgeServerRequest::class => MockResponse::fixture('singleServer')
]);
// The initial request will check if a fixture called "singleServer"
// exists. Because it doesn't exist yet, the real request will be
// sent and the response will be recorded.
$request = new GetForgeServerRequest(12345);
$response = $request->send();
// However, the next time the request is made, the fixture will
// exist, and Saloon will not make the request again.
$request = new GetForgeServerRequest(12345);
$response = $request->send();Namespacing
Configuration
Fixture Path
Preventing Unwanted Requests
Advanced Usage
Last updated