SaloonManager
class SaloonManager
Properties
| protected MiddlewarePipeline | $middleware | The middleware applied to every Saloon request. |
|
| protected null|PendingRequest): ?string | $cacheScopeResolver | The cache scope resolver. |
|
| protected string|null | $fixturePath | The tests-only fixture path override. |
|
| protected bool|null | $throwOnMissingFixtures | The tests-only missing fixture behavior override. |
|
| protected MockClient|null | $mockClient | The tests-only global mock client. |
Methods
Create the Saloon manager.
Send a request through a connector.
Prepare a request for sending through a connector.
Inspect a connector or request rate limit without consuming it.
Get the global middleware pipeline.
Add responses to the global mock client, or replace it with the given client.
Get the global mock client.
Clear the global mock client.
Assert that a matching request was sent.
Assert that no matching request was sent.
Assert that requests were sent in order.
Assert that nothing was sent.
Assert the number of recorded requests.
Clear the cached response for a request without sending it.
Set the fixture storage path.
Get the fixture storage path.
Configure missing fixture behavior.
Determine if missing fixtures should throw.
Sleep for a checked number of milliseconds.
Resolve the cache store and bounded key for an operation.
Enforce connector and request rate limits before transport.
Enforce one rate-limited resource.
Record connector and request cooldowns from a transport response.
Record one resource's response-derived cooldown.
Resolve the limiter name used for a resource's limits and cooldowns.
Wait for a denied policy or throw its result.
Details
at line 80
__construct(Sender $sender, Factory $cache, RateLimiter $rateLimiter, Repository $config, Dispatcher $events)
Create the Saloon manager.
at line 97
Response
send(Connector $connector, Request $request, MockClient|null $mockClient = null)
Send a request through a connector.
at line 273
PendingRequest
createPendingRequest(Connector $connector, Request $request)
Prepare a request for sending through a connector.
The pending request has run its plugins, authenticator, boot hooks and request middleware, in that order. It has not been finalized, matched against mock responses or sent.
Middleware is registered on the operation's own pipeline in this order: global middleware, plugin middleware, middleware added by the connector's boot method, the request's middleware, then middleware added by the request's boot method. Connectors are read-only, so connector middleware is registered from the boot method and still runs before the request's.
at line 292
LimitResult|CooldownResult
inspectRateLimit(Connector|Request $resource, AdmissionPolicy|Cooldown $policy)
Inspect a connector or request rate limit without consuming it.
at line 303
void
setEventDispatcher(Dispatcher $events)
Set the event dispatcher.
On the shared manager, the dispatcher persists for the worker lifetime and receives every subsequent Saloon request event.
at line 315
MiddlewarePipeline
middleware()
Get the global middleware pipeline.
On the shared manager, middleware added to this pipeline persists for the worker lifetime and affects every subsequent Saloon request.
at line 328
MockClient
fake(array|MockClient $responses = [])
Add responses to the global mock client, or replace it with the given client.
The client persists on the manager until the test application
is destroyed or clearFake() is called.
at line 343
MockClient|null
mockClient()
Get the global mock client.
at line 356
SaloonManager
clearFake()
Clear the global mock client.
On the shared manager, this immediately removes the recorder for every subsequent Saloon request in the worker.
at line 367
void
assertSent(string|callable $value)
Assert that a matching request was sent.
at line 375
void
assertNotSent(string|callable $value)
Assert that no matching request was sent.
at line 385
void
assertSentInOrder(array $callbacks)
Assert that requests were sent in order.
at line 393
void
assertNothingSent()
Assert that nothing was sent.
at line 403
void
assertSentCount(int $count, string|null $requestClass = null)
Assert the number of recorded requests.
at line 420
SaloonManager
resolveCacheScopeUsing(Closure|null $resolver)
Register the cache scope resolver.
On the shared manager, the callback persists for the worker lifetime and affects every subsequently cached Saloon request.
at line 431
string|null
resolveCacheScope(PendingRequest $pendingRequest)
Resolve the cache scope for the request.
at line 444
void
clearCache(Connector $connector, Request $request)
Clear the cached response for a request without sending it.
The request is prepared as it is for sending, through its plugins, boot methods and middleware, so the same store, key and scope are resolved. Sending listeners do not run.
at line 462
SaloonManager
fixturePath(string $path)
Set the fixture storage path.
The override persists on the manager until the test application is destroyed.
at line 473
string
getFixturePath()
Get the fixture storage path.
at line 488
SaloonManager
throwOnMissingFixtures(bool $throw = true)
Configure missing fixture behavior.
The override persists on the manager until the test application is destroyed.
at line 499
bool
throwsOnMissingFixtures()
Determine if missing fixtures should throw.
at line 508
protected void
sleepMilliseconds(int $milliseconds)
Sleep for a checked number of milliseconds.
at line 526
protected array
resolveCache(PendingRequest $pendingRequest, array $transport)
Resolve the cache store and bounded key for an operation.
at line 549
protected void
enforceRateLimits(PendingRequest $pendingRequest)
Enforce connector and request rate limits before transport.
at line 558
protected void
enforceRateLimitsFor(PendingRequest $pendingRequest, Connector|Request $resource)
Enforce one rate-limited resource.
at line 608
protected void
recordRateLimitCooldowns(PendingRequest $pendingRequest, Response $response)
Record connector and request cooldowns from a transport response.
at line 617
protected void
recordRateLimitCooldownFor(PendingRequest $pendingRequest, Response $response, Connector|Request $resource)
Record one resource's response-derived cooldown.
at line 637
protected string
limiterNameFor(Connector|Request $resource)
Resolve the limiter name used for a resource's limits and cooldowns.
at line 645
protected Limiter
rateLimiterFor(Connector|Request $resource)
Resolve the framework limiter selected by a resource.
at line 658
protected void
waitForRateLimit(Connector|Request $resource, AdmissionPolicy|Cooldown $policy, Decision $result)
Wait for a denied policy or throw its result.