diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 105695c963d91..13c63ff9988d5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -1482,7 +1482,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode) ->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() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_scoped_without_query_option.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_scoped_without_query_option.php new file mode 100644 index 0000000000000..0d3dc88472f84 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_scoped_without_query_option.php @@ -0,0 +1,11 @@ +loadFromExtension('framework', [ + 'http_client' => [ + 'scoped_clients' => [ + 'foo' => [ + 'scope' => '.*', + ], + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_scoped_without_query_option.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_scoped_without_query_option.xml new file mode 100644 index 0000000000000..43043aeda2a01 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_scoped_without_query_option.xml @@ -0,0 +1,16 @@ + + + + + + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_scoped_without_query_option.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_scoped_without_query_option.yml new file mode 100644 index 0000000000000..ecfc9d41fd4c3 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_scoped_without_query_option.yml @@ -0,0 +1,5 @@ +framework: + http_client: + scoped_clients: + foo: + scope: '.*' diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index edcdb7aae487f..9301e9c10cb48 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -1547,6 +1547,15 @@ public function testHttpClientDefaultOptions() $this->assertSame(ScopingHttpClient::class, $container->getDefinition('foo')->getClass()); } + public function testScopedHttpClientWithoutQueryOption() + { + $container = $this->createContainerFromFile('http_client_scoped_without_query_option'); + $this->assertTrue($container->hasDefinition('http_client'), '->registerHttpClientConfiguration() loads http_client.xml'); + + $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');