Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:7.0fromGaryPEGEOT:feat/har-response-factory
Jul 9, 2023
Merged

[HttpClient] Add an HAR response factory for testing#50807

fabpot merged 1 commit intosymfony:7.0fromGaryPEGEOT:feat/har-response-factory
Jul 9, 2023

Conversation

@GaryPEGEOT
Copy link
Contributor

@GaryPEGEOTGaryPEGEOT commentedJun 28, 2023
edited
Loading

QA
Branch?6.4
Bug fix?no
New feature?yes
Deprecations?no
Tickets
LicenseMIT
Doc PRTODO

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:

// Inside a KernelTestCase// ...$factory =newHarFileResponseFactory('path/to/some_file.har');static::getContainer()->get('http_client')->setResponseFactory($factory);// Will find the suitable response(s) inside some_file.har$myServiceWithHttpCalls->doSomething();

Nyholm reacted with thumbs up emojifancyweb and welcoMattic reacted with heart emoji
Copy link
Member

@NyholmNyholm left a 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 suggestyielding. That means we can do:

$factory =newHarFileResponseFactory($myHarFile);$client =newMockHttpClient($factory);

fancyweb reacted with thumbs up emoji
$json = json_decode(
json: file_get_contents($this->archiveFile),
associative: true,
flags: \JSON_THROW_ON_ERROR
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
flags: \JSON_THROW_ON_ERROR
flags: \JSON_THROW_ON_ERROR,

Copy link
Member

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.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Fixed!

@fabpotfabpot modified the milestones:6.4,7.0Jul 9, 2023
@fabpot
Copy link
Member

Can you rebase on 7.0 and add a note in the CHANGELOG?

@fabpot
Copy link
Member

Thank you@GaryPEGEOT.

@fabpotfabpot merged commitc63faff intosymfony:7.0Jul 9, 2023
@GaryPEGEOTGaryPEGEOT deleted the feat/har-response-factory branchJuly 9, 2023 11:16
@nicolas-grekasnicolas-grekas modified the milestones:7.0,6.4Jul 20, 2023
@fabpotfabpot mentioned this pull requestOct 21, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof left review comments

@fabpotfabpotfabpot approved these changes

@NyholmNyholmNyholm approved these changes

@xabbuhxabbuhAwaiting requested review from xabbuh

@lyrixxlyrixxAwaiting requested review from lyrixx

@dunglasdunglasAwaiting requested review from dunglas

@ycerutoycerutoAwaiting requested review from yceruto

@kbondkbondAwaiting requested review from kbond

@wouterjwouterjAwaiting requested review from wouterj

@chalasrchalasrAwaiting requested review from chalasr

@OskarStarkOskarStarkAwaiting requested review from OskarStark

@jderussejderusseAwaiting requested review from jderusse

Assignees

No one assigned

Projects

None yet

Milestone

6.4

Development

Successfully merging this pull request may close these issues.

6 participants

@GaryPEGEOT@fabpot@stof@Nyholm@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp