Skip to content

Commit 88994e2

Browse files
authored
clarify mocking in symfony
1 parent 6f259c1 commit 88994e2

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

clients/mock-client.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,24 @@ Or pass a callable, and return a response or exception based on the request::
226226

227227
.. hint::
228228

229-
If you're using the :doc:`/integrations/symfony-bundle`, the mock client is available as a service with ``httplug.client.mock`` id.
229+
If you're using the :doc:`/integrations/symfony-bundle`, the mock client is
230+
available as a service with ``httplug.client.mock`` id.
231+
232+
For functional tests, you can overwrite the http client services with the mock
233+
client in the test environment:
234+
235+
# config/services_test.yaml
236+
services:
237+
# overwrite the http clients for mocking
238+
httplug.client.my_client:
239+
class: Http\Mock\Client
240+
public: true
241+
242+
This will configure your actual services with the mock client. Setting the service
243+
public allows you to fetch the mock client from the container to configure it.
244+
245+
Note that if you enable a decorator client, e.g. ``http_methods_client: true``,
246+
the mock client will be wrapped as well. As usual, the inner client is available
247+
by appending ``.inner`` to the service name, e.g. ``httplug.client.my_client.inner``.
230248

231249
.. include:: includes/further-reading-async.inc

0 commit comments

Comments
 (0)