-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpClient] Add a mock client #30553
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
Maybe could we also add a helper to create mock responses? Especially, implementing new MockResponse(/* all args are optional */
'content',
200,
['X-Foo' => 'custom header, mandatory headers will be automatically populated'],
['x-info' => ['custom info, mandatory keys, including raw_headers will be automatically populated']
); |
@dunglas just added the |
It looks great! |
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.
1st round :)
@@ -5,3 +5,4 @@ CHANGELOG | |||
----- | |||
|
|||
* added the component | |||
* added a mock client |
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.
no need to add this in the changelog, as there is no component at all in previous version, so added the component
describes the changes already.
} | ||
|
||
/** | ||
* Clear all predefined responses. |
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.
Clears
{ | ||
use ResponseTrait; | ||
|
||
protected const DEFAULT_INFO = [ |
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.
should be private rather than protected IMO, following our convention of not using protected
without having a clear use case for inheritance.
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.
and change the access to self::
, as using static::
to access a private thing is broken.
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
A big thank you for starting this, I submitted another complete implementation in #30604. |
Add a new
MockClient
usable for test purpose:WDYT?