Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Support the sink option when using Http::fake() #33720

Merged
merged 2 commits into from
Aug 1, 2020
Merged

[7.x] Support the sink option when using Http::fake() #33720

merged 2 commits into from
Aug 1, 2020

Conversation

SjorsO
Copy link
Contributor

@SjorsO SjorsO commented Jul 31, 2020

The Guzzle sink option allows you to save the body of the response directly to a file or resource. When using the Http client, sink works normally. As soon as you call Http::fake(), the sink option stops working, making it impossible to test code that uses the sink option.

This PR adds support for two common sink use-cases: saving to a file and writing to a stream. There might be more ways to use the sink option, but I couldn't figure out exactly how Guzzle handles sinking. We can fix other use-cases once people run into them.

This PR also adds a sink() method to the PendingRequest class. This makes it easier to use the option, and allows IDEs to help with auto completion.


Fixes #33557

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.

Http::withOptions('sink' => $path) has no effect with Http::fake
2 participants