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] Fix handling error info in MockResponse#44361

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

Conversation

@fancyweb
Copy link
Contributor

@fancywebfancyweb commentedNov 30, 2021
edited
Loading

QA
Branch?4.4
Bug fix?yes
New feature?no
Deprecations?no
Tickets-
LicenseMIT
Doc PR-

Usingnew MockResponse('', ['error' => 'foobar']) with theMockHttpClient, I expect aTransportException to be thrown if I callgetStatusCode(),getHeaders(),getContent() ortoArray().

Currently, it does not work forgetStatusCode() andgetHeaders() becauseMockResponse only "converts" the passed error to an exception after the full response workflow has been simulated.getStatusCode() andgetHeaders() stops at the first chunk so it cannot work. I propose to throw at the beginning of the simulated response reading.


$responses[] =$mock;
$responses[] =$mock;
$responses[] =$mockResponse =newMockResponse('', ['error' =>'DNS error']);
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

We don't need to mock anymore becausegetStatusCode() will throw properly.

$mock->expects($this->any())
->method('getContent')
->willReturnCallback(staticfunction ():void {
usleep(100000);
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thisusleep was useless.

@fancywebfancywebforce-pushed thehttp-client/mock-error-init branch fromd122b38 to784eddeCompareNovember 30, 2021 12:44
@fancywebfancywebforce-pushed thehttp-client/mock-error-init branch from784edde to369d9d7CompareNovember 30, 2021 17:02
@nicolas-grekas
Copy link
Member

Thank you@fancyweb.

@nicolas-grekasnicolas-grekas merged commitdaba023 intosymfony:4.4Dec 1, 2021
@fancywebfancyweb deleted the http-client/mock-error-init branchDecember 1, 2021 13:52
This was referencedDec 9, 2021
This was referencedDec 29, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

+1 more reviewer

@youssefsaoubouyoussefsaoubouyoussefsaoubou left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

4 participants

@fancyweb@nicolas-grekas@youssefsaoubou@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp