[HttpClient] Use decoration instead of class replacement for mock factory
This commit is contained in:
parent
42f440ec25
commit
9a9823c99a
@ -2071,8 +2071,8 @@ class FrameworkExtension extends Extension
|
||||
}
|
||||
|
||||
if ($responseFactoryId = $config['mock_response_factory'] ?? null) {
|
||||
$container->getDefinition($httpClientId)
|
||||
->setClass(MockHttpClient::class)
|
||||
$container->register($httpClientId.'.mock_client', MockHttpClient::class)
|
||||
->setDecoratedService($httpClientId, null, -10) // lower priority than TraceableHttpClient
|
||||
->setArguments([new Reference($responseFactoryId)]);
|
||||
}
|
||||
}
|
||||
|
@ -1611,7 +1611,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
{
|
||||
$container = $this->createContainerFromFile('http_client_mock_response_factory');
|
||||
|
||||
$definition = $container->getDefinition('http_client');
|
||||
$definition = $container->getDefinition('http_client.mock_client');
|
||||
|
||||
$this->assertSame(MockHttpClient::class, $definition->getClass());
|
||||
$this->assertCount(1, $definition->getArguments());
|
||||
@ -1619,6 +1619,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$argument = $definition->getArgument(0);
|
||||
|
||||
$this->assertInstanceOf(Reference::class, $argument);
|
||||
$this->assertSame('http_client', current($definition->getDecoratedService()));
|
||||
$this->assertSame('my_response_factory', (string) $argument);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user