Skip to content

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

Merged
taylorotwell merged 2 commits into
laravel:7.xfrom
SjorsO:http-sink
Aug 1, 2020
Merged

taylorotwell merged 2 commits into
laravel:7.xfrom
SjorsO:http-sink

Conversation

@SjorsO

@SjorsO SjorsO commented Jul 31, 2020 •

Copy link
Copy Markdown
Contributor

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

@taylorotwell
taylorotwell merged commit 21d17fe into laravel:7.x Aug 1, 2020
salmanarshad321 pushed a commit to salmanarshad321/framework that referenced this pull request Sep 23, 2026
* support the sink option in http::fake()

* fix sink option when stubbing paths
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