2323 */
2424class ConfigDebugCommandTest extends AbstractWebTestCase
2525{
26- private $ application ;
27-
28- protected function setUp (): void
26+ /**
27+ * @testWith [true]
28+ * [false]
29+ */
30+ public function testDumpKernelExtension (bool $ debug )
2931 {
30- $ kernel = static ::createKernel (['test_case ' => 'ConfigDump ' , 'root_config ' => 'config.yml ' ]);
31- $ this ->application = new Application ($ kernel );
32- $ this ->application ->doRun (new ArrayInput ([]), new NullOutput ());
32+ $ tester = $ this ->createCommandTester ($ debug );
33+ $ ret = $ tester ->execute (['name ' => 'foo ' ]);
34+
35+ $ this ->assertSame (0 , $ ret , 'Returns 0 in case of success ' );
36+ $ this ->assertStringContainsString ('foo: ' , $ tester ->getDisplay ());
37+ $ this ->assertStringContainsString (' foo: bar ' , $ tester ->getDisplay ());
3338 }
3439
35- public function testDumpBundleName ()
40+ /**
41+ * @testWith [true]
42+ * [false]
43+ */
44+ public function testDumpBundleName (bool $ debug )
3645 {
37- $ tester = $ this ->createCommandTester ();
46+ $ tester = $ this ->createCommandTester ($ debug );
3847 $ ret = $ tester ->execute (['name ' => 'TestBundle ' ]);
3948
4049 $ this ->assertSame (0 , $ ret , 'Returns 0 in case of success ' );
4150 $ this ->assertStringContainsString ('custom: foo ' , $ tester ->getDisplay ());
4251 }
4352
44- public function testDumpBundleOption ()
53+ /**
54+ * @testWith [true]
55+ * [false]
56+ */
57+ public function testDumpBundleOption (bool $ debug )
4558 {
46- $ tester = $ this ->createCommandTester ();
59+ $ tester = $ this ->createCommandTester ($ debug );
4760 $ ret = $ tester ->execute (['name ' => 'TestBundle ' , 'path ' => 'custom ' ]);
4861
4962 $ this ->assertSame (0 , $ ret , 'Returns 0 in case of success ' );
5063 $ this ->assertStringContainsString ('foo ' , $ tester ->getDisplay ());
5164 }
5265
53- public function testParametersValuesAreResolved ()
66+ /**
67+ * @testWith [true]
68+ * [false]
69+ */
70+ public function testParametersValuesAreResolved (bool $ debug )
5471 {
55- $ tester = $ this ->createCommandTester ();
72+ $ tester = $ this ->createCommandTester ($ debug );
5673 $ ret = $ tester ->execute (['name ' => 'framework ' ]);
5774
5875 $ this ->assertSame (0 , $ ret , 'Returns 0 in case of success ' );
5976 $ this ->assertStringContainsString ("locale: '%env(LOCALE)%' " , $ tester ->getDisplay ());
6077 $ this ->assertStringContainsString ('secret: test ' , $ tester ->getDisplay ());
6178 }
6279
63- public function testDefaultParameterValueIsResolvedIfConfigIsExisting ()
80+ /**
81+ * @testWith [true]
82+ * [false]
83+ */
84+ public function testDefaultParameterValueIsResolvedIfConfigIsExisting (bool $ debug )
6485 {
65- $ tester = $ this ->createCommandTester ();
86+ $ tester = $ this ->createCommandTester ($ debug );
6687 $ ret = $ tester ->execute (['name ' => 'framework ' ]);
6788
6889 $ this ->assertSame (0 , $ ret , 'Returns 0 in case of success ' );
69- $ kernelCacheDir = $ this -> application -> getKernel () ->getContainer ()->getParameter ('kernel.cache_dir ' );
90+ $ kernelCacheDir = self :: $ kernel ->getContainer ()->getParameter ('kernel.cache_dir ' );
7091 $ this ->assertStringContainsString (sprintf ("dsn: 'file:%s/profiler' " , $ kernelCacheDir ), $ tester ->getDisplay ());
7192 }
7293
73- public function testDumpExtensionConfigWithoutBundle ()
94+ /**
95+ * @testWith [true]
96+ * [false]
97+ */
98+ public function testDumpExtensionConfigWithoutBundle (bool $ debug )
7499 {
75- $ tester = $ this ->createCommandTester ();
100+ $ tester = $ this ->createCommandTester ($ debug );
76101 $ ret = $ tester ->execute (['name ' => 'test_dump ' ]);
77102
78103 $ this ->assertSame (0 , $ ret , 'Returns 0 in case of success ' );
79104 $ this ->assertStringContainsString ('enabled: true ' , $ tester ->getDisplay ());
80105 }
81106
82- public function testDumpUndefinedBundleOption ()
107+ /**
108+ * @testWith [true]
109+ * [false]
110+ */
111+ public function testDumpUndefinedBundleOption (bool $ debug )
83112 {
84- $ tester = $ this ->createCommandTester ();
113+ $ tester = $ this ->createCommandTester ($ debug );
85114 $ tester ->execute (['name ' => 'TestBundle ' , 'path ' => 'foo ' ]);
86115
87116 $ this ->assertStringContainsString ('Unable to find configuration for "test.foo" ' , $ tester ->getDisplay ());
88117 }
89118
90- public function testDumpWithPrefixedEnv ()
119+ /**
120+ * @testWith [true]
121+ * [false]
122+ */
123+ public function testDumpWithPrefixedEnv (bool $ debug )
91124 {
92- $ tester = $ this ->createCommandTester ();
125+ $ tester = $ this ->createCommandTester ($ debug );
93126 $ tester ->execute (['name ' => 'FrameworkBundle ' ]);
94127
95128 $ this ->assertStringContainsString ("cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%' " , $ tester ->getDisplay ());
96129 }
97130
98- public function testDumpFallsBackToDefaultConfigAndResolvesParameterValue ()
131+ /**
132+ * @testWith [true]
133+ * [false]
134+ */
135+ public function testDumpFallsBackToDefaultConfigAndResolvesParameterValue (bool $ debug )
99136 {
100- $ tester = $ this ->createCommandTester ();
137+ $ tester = $ this ->createCommandTester ($ debug );
101138 $ ret = $ tester ->execute (['name ' => 'DefaultConfigTestBundle ' ]);
102139
103140 $ this ->assertSame (0 , $ ret , 'Returns 0 in case of success ' );
104141 $ this ->assertStringContainsString ('foo: bar ' , $ tester ->getDisplay ());
105142 }
106143
107- public function testDumpFallsBackToDefaultConfigAndResolvesEnvPlaceholder ()
144+ /**
145+ * @testWith [true]
146+ * [false]
147+ */
148+ public function testDumpFallsBackToDefaultConfigAndResolvesEnvPlaceholder (bool $ debug )
108149 {
109- $ tester = $ this ->createCommandTester ();
150+ $ tester = $ this ->createCommandTester ($ debug );
110151 $ ret = $ tester ->execute (['name ' => 'DefaultConfigTestBundle ' ]);
111152
112153 $ this ->assertSame (0 , $ ret , 'Returns 0 in case of success ' );
113154 $ this ->assertStringContainsString ("baz: '%env(BAZ)%' " , $ tester ->getDisplay ());
114155 }
115156
116- public function testDumpThrowsExceptionWhenDefaultConfigFallbackIsImpossible ()
157+ /**
158+ * @testWith [true]
159+ * [false]
160+ */
161+ public function testDumpThrowsExceptionWhenDefaultConfigFallbackIsImpossible (bool $ debug )
117162 {
118163 $ this ->expectException (\LogicException::class);
119164 $ this ->expectExceptionMessage ('The extension with alias "extension_without_config_test" does not have configuration. ' );
120165
121- $ tester = $ this ->createCommandTester ();
166+ $ tester = $ this ->createCommandTester ($ debug );
122167 $ tester ->execute (['name ' => 'ExtensionWithoutConfigTestBundle ' ]);
123168 }
124169
125170 /**
126171 * @dataProvider provideCompletionSuggestions
127172 */
128- public function testComplete (array $ input , array $ expectedSuggestions )
173+ public function testComplete (bool $ debug , array $ input , array $ expectedSuggestions )
129174 {
130- $ this ->application ->add (new ConfigDebugCommand ());
131-
132- $ tester = new CommandCompletionTester ($ this ->application ->get ('debug:config ' ));
175+ $ application = $ this ->createApplication ($ debug );
133176
177+ $ application ->add (new ConfigDebugCommand ());
178+ $ tester = new CommandCompletionTester ($ application ->get ('debug:config ' ));
134179 $ suggestions = $ tester ->complete ($ input );
135180
136181 foreach ($ expectedSuggestions as $ expectedSuggestion ) {
@@ -140,17 +185,32 @@ public function testComplete(array $input, array $expectedSuggestions)
140185
141186 public static function provideCompletionSuggestions (): \Generator
142187 {
143- yield 'name ' => [['' ], ['default_config_test ' , 'extension_without_config_test ' , 'framework ' , 'test ' ]];
188+ $ name = ['default_config_test ' , 'extension_without_config_test ' , 'framework ' , 'test ' ];
189+ yield 'name, no debug ' => [false , ['' ], $ name ];
190+ yield 'name, debug ' => [true , ['' ], $ name ];
144191
145- yield 'name (started CamelCase) ' => [['Fra ' ], ['DefaultConfigTestBundle ' , 'ExtensionWithoutConfigTestBundle ' , 'FrameworkBundle ' , 'TestBundle ' ]];
192+ $ nameCamelCased = ['DefaultConfigTestBundle ' , 'ExtensionWithoutConfigTestBundle ' , 'FrameworkBundle ' , 'TestBundle ' ];
193+ yield 'name (started CamelCase), no debug ' => [false , ['Fra ' ], $ nameCamelCased ];
194+ yield 'name (started CamelCase), debug ' => [true , ['Fra ' ], $ nameCamelCased ];
146195
147- yield 'name with existing path ' => [['framework ' , '' ], ['secret ' , 'router.resource ' , 'router.utf8 ' , 'router.enabled ' , 'validation.enabled ' , 'default_locale ' ]];
196+ $ nameWithPath = ['secret ' , 'router.resource ' , 'router.utf8 ' , 'router.enabled ' , 'validation.enabled ' , 'default_locale ' ];
197+ yield 'name with existing path, no debug ' => [false , ['framework ' , '' ], $ nameWithPath ];
198+ yield 'name with existing path, debug ' => [true , ['framework ' , '' ], $ nameWithPath ];
148199 }
149200
150- private function createCommandTester (): CommandTester
201+ private function createCommandTester (bool $ debug ): CommandTester
151202 {
152- $ command = $ this ->application ->find ('debug:config ' );
203+ $ command = $ this ->createApplication ( $ debug ) ->find ('debug:config ' );
153204
154205 return new CommandTester ($ command );
155206 }
207+
208+ private function createApplication (bool $ debug ): Application
209+ {
210+ $ kernel = static ::bootKernel (['debug ' => $ debug , 'test_case ' => 'ConfigDump ' , 'root_config ' => 'config.yml ' ]);
211+ $ application = new Application ($ kernel );
212+ $ application ->doRun (new ArrayInput ([]), new NullOutput ());
213+
214+ return $ application ;
215+ }
156216}
0 commit comments