[HttpClient] Fix scoped client without query option configuration
This commit is contained in:
parent
f72dd9cafa
commit
a07578dba3
@ -1482,7 +1482,7 @@ class Configuration implements ConfigurationInterface
|
||||
->thenInvalid('Either "scope" or "base_uri" should be defined.')
|
||||
->end()
|
||||
->validate()
|
||||
->ifTrue(function ($v) { return isset($v['query']) && !isset($v['base_uri']); })
|
||||
->ifTrue(function ($v) { return !empty($v['query']) && !isset($v['base_uri']); })
|
||||
->thenInvalid('"query" applies to "base_uri" but no base URI is defined.')
|
||||
->end()
|
||||
->children()
|
||||
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'http_client' => [
|
||||
'scoped_clients' => [
|
||||
'foo' => [
|
||||
'scope' => '.*',
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:http-client>
|
||||
<framework:scoped-client
|
||||
name="foo"
|
||||
scope=".*"
|
||||
/>
|
||||
</framework:http-client>
|
||||
</framework:config>
|
||||
</container>
|
@ -0,0 +1,5 @@
|
||||
framework:
|
||||
http_client:
|
||||
scoped_clients:
|
||||
foo:
|
||||
scope: '.*'
|
@ -1547,6 +1547,14 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->assertSame(ScopingHttpClient::class, $container->getDefinition('foo')->getClass());
|
||||
}
|
||||
|
||||
public function testScopedHttpClientWithoutQueryOption()
|
||||
{
|
||||
$container = $this->createContainerFromFile('http_client_scoped_without_query_option');
|
||||
|
||||
$this->assertTrue($container->hasDefinition('foo'), 'should have the "foo" service.');
|
||||
$this->assertSame(ScopingHttpClient::class, $container->getDefinition('foo')->getClass());
|
||||
}
|
||||
|
||||
public function testHttpClientOverrideDefaultOptions()
|
||||
{
|
||||
$container = $this->createContainerFromFile('http_client_override_default_options');
|
||||
|
Reference in New Issue
Block a user