From f86a875ebd18e6a8d5398f657ebc134309213158 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Mon, 22 Jan 2018 11:17:25 -0500 Subject: [PATCH] fixing bug with merging config --- src/DependencyInjection/Configuration.php | 2 ++ .../DependencyInjection/ConfigurationTest.php | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 1689f248..bc1c8713 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -23,6 +23,8 @@ public function getConfigTreeBuilder() $rootNode ->children() ->arrayNode('clients') + ->normalizeKeys(false) + ->useAttributeAsKey('variable') ->prototype('array') ->prototype('variable')->end() ->end() diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index 6b071a85..f39bb68a 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -73,4 +73,31 @@ public function provideConfigurationTests() return $tests; } + + public function testClientMergingConfig() + { + $fbConfig = [ + 'type' => 'facebook', + 'client_id' => 'ABC', + 'client_secret' => '123', + 'graph_api_version' => '2.3', + 'redirect_route' => 'my_route', + 'redirect_params' => ['foo' => 'bars'], + ]; + + $processor = new Processor(); + + $config = $processor->processConfiguration( + new Configuration(), [ + ['clients' => ['fb1' => $fbConfig]], + ['clients' => ['fb2' => $fbConfig]], + ] + ); + + // verify the client keys are merged nicely + $this->assertSame( + ['fb1', 'fb2'], + array_keys($config['clients']) + ); + } }