Skip to content

Add MockClient::withoutCache()#548

Open
JonPurvis wants to merge 1 commit intosaloonphp:v4from
JonPurvis:fix/547-fake-without-cache
Open

Add MockClient::withoutCache()#548
JonPurvis wants to merge 1 commit intosaloonphp:v4from
JonPurvis:fix/547-fake-without-cache

Conversation

@JonPurvis
Copy link
Copy Markdown
Contributor

@JonPurvis JonPurvis commented Apr 12, 2026

Important

Merge this one first and then the Cache plugin

Sister PR: saloonphp/cache-plugin#18
Fixes: #547

When the response cache plugin runs, it can read and write cached payloads before mocked responses are resolved again. That makes fixture-based mocks appear stuck after the first request.

This PR adds an explicit opt-out on MockClient:

  • withoutCache(): mark this mock client so downstream code can skip response caching
  • shouldBypassResponseCache(): query that flag (used by the cache plugin)

Saloon::fake([...])->withoutCache() continues to work because the Laravel helper returns the global MockClient.

This PR also Includes a unit test covering the addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable caching in tests

1 participant