-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Description
Description
Hi,
Symfony has infrastructure to start a test HTTP server process. With #50814 it can now specify your working directory.
It would be nice if all configured HTTP clients are proxied/routed to this test server 'when at test env' (when@test
), thus without changing any request URL or so.
We'd ensure no external traffic occurs by default, unless a client opts-out for reasons. I recently discovered we fetch some external Soap WSDLs lazily (if not cached).
Mocking the endpoint should be effortless: match request => provide response, be done. This can now be achieved by leveraging some designated working directory (tests/Fixtures/Http/
), to be fed to TestHttpServer::start()
, to be triggered by FrameworkBundle::boot()
or so.
In practice it would look like:
when@test:
http_test_server:
enabled: true
port: 1337
excluded_clients: []
working_dir: 'tests/Fixtures/Http'
(eg. to be provided in at the recipe level)
The remaining question would be how we arrange tests/Fixtures/Http
and write actual fixtures. Perhaps we can benefit from existing response classes to provide a mock.
# tests/Fixtures/Http/domain.com.php
return fn(Request $r): Response {
};
Thoughts?
Example
No response