Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Cannot use framework.http_client.mock_response_factory #39266

Closed
@Toflar

Description

@Toflar

Symfony version(s) affected: 5.2.0

Description

Whenever I want to use the new framework.http_client.mock_response_factory option introduced in #35893, I get the following error:

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service ".debug.http_client.inner".

How to reproduce

Configure

framework:
    test: true
    session:
        storage_id: session.storage.mock_file

    http_client:
        mock_response_factory: 'some_factory_id'

and let the container build.

Possible Solution

I think that's because the debug clients are only registered in the HttpClientPass which is excecuted after the extension.
Not really sure how this is supposed to work.

Moreover, I don't even see how that feature is supposed to work anyway:

if ($responseFactoryId = $config['mock_response_factory'] ?? null) {
$container->getDefinition($httpClientId)
->setClass(MockHttpClient::class)
->setArguments([new Reference($responseFactoryId)]);
}

How does setClass() help here? The http client services are created using the HttpClient::create() factory so without resetting the factory, this here cannot work?

Pinging @GaryPEGEOT as the original author of that feature, maybe I missed something completely :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions