Support for multiple mock clients
localheinz opened this issue · 4 comments
| Q | A |
|---|---|
| Bug? | no |
| New Feature? | yes |
| Version | Specific version or SHA of a commit |
Actual Behavior
Currently there is a single service with the identifier 'httplug.client.mock' available, which can be retrieved in functional tests to configure matchers for requests and responses.
This is fine when working
- with an application where only a single client is configured
- in a context where it doesn't matter which client is sending requests
When we are working with an application where that's not the case, that is, when working
- with an application where multiple clients are configured
- in a context where it it matters which client is sending requests
it seems to be quite an effort to set up mock clients in such a way that they can be retrieved in functional tests to set up expectations.
Do you have an idea for how to make that easier?
i see what you mean, and wonder if it even makes sense to expose the mock client as a service at all. symfony 4 allows to replace services with mocks, i think that would be much more explicit and easy to set up the expected mocking. see for example http://www.inanzzz.com/index.php/post/fsgx/overriding-symfony-private-services-for-functional-testing-with-phpunit (not sure about the service naming the author uses, but the code example should work)
Thank you, @dbu - I'm going to take a look!
are you ok to close this, with #348? i think that is the better solution than expanding the configuration which seems more fragile than the solution you implemented there.
👍