1111 */
1212class ConfigurationTest extends AbstractExtensionConfigurationTestCase
1313{
14- private $ debug = true ;
14+ private $ emptyConfig = [
15+ 'main_alias ' => [
16+ 'client ' => 'httplug.client.default ' ,
17+ 'message_factory ' => 'httplug.message_factory.default ' ,
18+ 'uri_factory ' => 'httplug.uri_factory.default ' ,
19+ 'stream_factory ' => 'httplug.stream_factory.default ' ,
20+ ],
21+ 'classes ' => [
22+ 'client ' => null ,
23+ 'message_factory ' => null ,
24+ 'uri_factory ' => null ,
25+ 'stream_factory ' => null ,
26+ ],
27+ 'clients ' => [],
28+ 'profiling ' => [
29+ 'enabled ' => true ,
30+ 'formatter ' => null ,
31+ 'captured_body_length ' => 0 ,
32+ ],
33+ 'plugins ' => [
34+ 'authentication ' => [],
35+ 'cache ' => [
36+ 'enabled ' => false ,
37+ 'stream_factory ' => 'httplug.stream_factory ' ,
38+ 'config ' => [
39+ 'default_ttl ' => null ,
40+ 'respect_cache_headers ' => true ,
41+ ],
42+ ],
43+ 'cookie ' => [
44+ 'enabled ' => false ,
45+ ],
46+ 'decoder ' => [
47+ 'enabled ' => true ,
48+ 'use_content_encoding ' => true ,
49+ ],
50+ 'history ' => [
51+ 'enabled ' => false ,
52+ ],
53+ 'logger ' => [
54+ 'enabled ' => true ,
55+ 'logger ' => 'logger ' ,
56+ 'formatter ' => null ,
57+ ],
58+ 'redirect ' => [
59+ 'enabled ' => true ,
60+ 'preserve_header ' => true ,
61+ 'use_default_for_multiple ' => true ,
62+ ],
63+ 'retry ' => [
64+ 'enabled ' => true ,
65+ 'retry ' => 1 ,
66+ ],
67+ 'stopwatch ' => [
68+ 'enabled ' => true ,
69+ 'stopwatch ' => 'debug.stopwatch ' ,
70+ ],
71+ ],
72+ 'discovery ' => [
73+ 'client ' => 'auto ' ,
74+ 'async_client ' => null ,
75+ ],
76+ ];
1577
1678 protected function getContainerExtension ()
1779 {
@@ -20,86 +82,21 @@ protected function getContainerExtension()
2082
2183 protected function getConfiguration ()
2284 {
23- return new Configuration ($ this -> debug );
85+ return new Configuration (true );
2486 }
2587
2688 public function testEmptyConfiguration ()
2789 {
28- $ expectedConfiguration = [
29- 'main_alias ' => [
30- 'client ' => 'httplug.client.default ' ,
31- 'message_factory ' => 'httplug.message_factory.default ' ,
32- 'uri_factory ' => 'httplug.uri_factory.default ' ,
33- 'stream_factory ' => 'httplug.stream_factory.default ' ,
34- ],
35- 'classes ' => [
36- 'client ' => null ,
37- 'message_factory ' => null ,
38- 'uri_factory ' => null ,
39- 'stream_factory ' => null ,
40- ],
41- 'clients ' => [],
42- 'toolbar ' => [
43- 'enabled ' => true ,
44- 'formatter ' => null ,
45- 'captured_body_length ' => 0 ,
46- ],
47- 'plugins ' => [
48- 'authentication ' => [],
49- 'cache ' => [
50- 'enabled ' => false ,
51- 'stream_factory ' => 'httplug.stream_factory ' ,
52- 'config ' => [
53- 'default_ttl ' => null ,
54- 'respect_cache_headers ' => true ,
55- ],
56- ],
57- 'cookie ' => [
58- 'enabled ' => false ,
59- ],
60- 'decoder ' => [
61- 'enabled ' => true ,
62- 'use_content_encoding ' => true ,
63- ],
64- 'history ' => [
65- 'enabled ' => false ,
66- ],
67- 'logger ' => [
68- 'enabled ' => true ,
69- 'logger ' => 'logger ' ,
70- 'formatter ' => null ,
71- ],
72- 'redirect ' => [
73- 'enabled ' => true ,
74- 'preserve_header ' => true ,
75- 'use_default_for_multiple ' => true ,
76- ],
77- 'retry ' => [
78- 'enabled ' => true ,
79- 'retry ' => 1 ,
80- ],
81- 'stopwatch ' => [
82- 'enabled ' => true ,
83- 'stopwatch ' => 'debug.stopwatch ' ,
84- ],
85- ],
86- 'discovery ' => [
87- 'client ' => 'auto ' ,
88- 'async_client ' => null ,
89- ],
90- ];
91-
9290 $ formats = array_map (function ($ path ) {
9391 return __DIR__ .'/../../Resources/Fixtures/ ' .$ path ;
9492 }, [
9593 'config/empty.yml ' ,
9694 'config/empty.xml ' ,
9795 'config/empty.php ' ,
98- 'config/toolbar_auto.yml ' ,
9996 ]);
10097
10198 foreach ($ formats as $ format ) {
102- $ this ->assertProcessedConfigurationEquals ($ expectedConfiguration , [$ format ]);
99+ $ this ->assertProcessedConfigurationEquals ($ this -> emptyConfig , [$ format ]);
103100 }
104101 }
105102
@@ -119,7 +116,7 @@ public function testSupportsAllConfigFormats()
119116 'stream_factory ' => 'Http\Message\StreamFactory\GuzzleStreamFactory ' ,
120117 ],
121118 'clients ' => [],
122- 'toolbar ' => [
119+ 'profiling ' => [
123120 'enabled ' => true ,
124121 'formatter ' => 'my_toolbar_formatter ' ,
125122 'captured_body_length ' => 0 ,
@@ -223,4 +220,28 @@ public function testInvalidAuthentication()
223220 $ file = __DIR__ .'/../../Resources/Fixtures/config/invalid_auth.yml ' ;
224221 $ this ->assertProcessedConfigurationEquals ([], [$ file ]);
225222 }
223+
224+ public function testBackwardCompatibility ()
225+ {
226+ $ formats = array_map (function ($ path ) {
227+ return __DIR__ .'/../../Resources/Fixtures// ' .$ path ;
228+ }, [
229+ 'config/bc/toolbar.yml ' ,
230+ 'config/bc/toolbar_auto.yml ' ,
231+ ]);
232+
233+ foreach ($ formats as $ format ) {
234+ $ this ->assertProcessedConfigurationEquals ($ this ->emptyConfig , [$ format ]);
235+ }
236+ }
237+
238+ /**
239+ * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
240+ * @expectedExceptionMessage "toolbar" config is deprecated as of version 1.3.0, please use "profiling" instead.
241+ */
242+ public function testProfilingToolbarCollision ()
243+ {
244+ $ file = __DIR__ .'/../../Resources/Fixtures/config/bc/profiling_toolbar.yml ' ;
245+ $ this ->assertProcessedConfigurationEquals ([], [$ file ]);
246+ }
226247}
0 commit comments