[HttpClient] Add a mock client#30553
[HttpClient] Add a mock client#30553GaryPEGEOT wants to merge 10 commits intosymfony:masterfrom GaryPEGEOT:feature/mock-client
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! |
| ----- | ||
|
|
||
| * added the component | ||
| * added a mock client |
There was a problem hiding this comment.
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. |
| { | ||
| use ResponseTrait; | ||
|
|
||
| protected const DEFAULT_INFO = [ |
There was a problem hiding this comment.
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.
and change the access to self::, as using static:: to access a private thing is broken.
|
A big thank you for starting this, I submitted another complete implementation in #30604. |
Add a new
MockClientusable for test purpose:WDYT?