Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
e2125b8 tod122b38CompareUh oh!
There was an error while loading.Please reload this page.
| $responses[] =$mock; | ||
| $responses[] =$mock; | ||
| $responses[] =$mockResponse =newMockResponse('', ['error' =>'DNS 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.
We don't need to mock anymore becausegetStatusCode() will throw properly.
| $mock->expects($this->any()) | ||
| ->method('getContent') | ||
| ->willReturnCallback(staticfunction ():void { | ||
| usleep(100000); |
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.
Thisusleep was useless.
Uh oh!
There was an error while loading.Please reload this page.
d122b38 to784eddeCompare784edde to369d9d7Comparenicolas-grekas commentedDec 1, 2021
Thank you@fancyweb. |
Uh oh!
There was an error while loading.Please reload this page.
Using
new MockResponse('', ['error' => 'foobar'])with theMockHttpClient, I expect aTransportExceptionto be thrown if I callgetStatusCode(),getHeaders(),getContent()ortoArray().Currently, it does not work for
getStatusCode()andgetHeaders()becauseMockResponseonly "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.