-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpClient] Add an HAR response factory for testing #50807
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
If the HAR file can contain multiple request/responses. Then I suggest yielding
. That means we can do:
$factory = new HarFileResponseFactory($myHarFile);
$client = new MockHttpClient($factory);
$json = json_decode( | ||
json: file_get_contents($this->archiveFile), | ||
associative: true, | ||
flags: \JSON_THROW_ON_ERROR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flags: \JSON_THROW_ON_ERROR | |
flags: \JSON_THROW_ON_ERROR, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's be consistent with the code base and use the "short" version here on one line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
Can you rebase on 7.0 and add a note in the CHANGELOG? |
9da54e4
to
0f9cb22
Compare
Thank you @GaryPEGEOT. |
bb758cc
to
01d2e35
Compare
From the network tab of most modern browsers, you can save one or more request as an HAR archive file. This pull request adds a way to use those files in test to replay responses previously saved.
Example usage: