Skip to content

Commit 37f3d29

Browse files
committed
do not revert tests changes
1 parent 679c656 commit 37f3d29

File tree

2 files changed

+135
-15
lines changed

2 files changed

+135
-15
lines changed

src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php

+62-7
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,78 @@ class ConfigurationTest extends TestCase
2020
/**
2121
* @dataProvider getDebugModes
2222
*/
23-
public function testConfigTree($options, $results)
23+
public function testConfigTree(array $options, array $expectedResult)
2424
{
2525
$processor = new Processor();
2626
$configuration = new Configuration();
2727
$config = $processor->processConfiguration($configuration, [$options]);
2828

29-
$this->assertEquals($results, $config);
29+
$this->assertEquals($expectedResult, $config);
3030
}
3131

3232
public function getDebugModes()
3333
{
3434
return [
35-
[[], ['intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt']],
36-
[['intercept_redirects' => true], ['intercept_redirects' => true, 'toolbar' => false, 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt']],
37-
[['intercept_redirects' => false], ['intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt']],
38-
[['toolbar' => true], ['intercept_redirects' => false, 'toolbar' => true, 'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt']],
39-
[['excluded_ajax_paths' => 'test'], ['intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => 'test']],
35+
[
36+
'options' => [],
37+
'expectedResult' => [
38+
'intercept_redirects' => false,
39+
'toolbar' => false,
40+
'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt',
41+
],
42+
],
43+
[
44+
'options' => ['toolbar' => true],
45+
'expectedResult' => [
46+
'intercept_redirects' => false,
47+
'toolbar' => true,
48+
'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt',
49+
],
50+
],
51+
[
52+
'options' => ['excluded_ajax_paths' => 'test'],
53+
'expectedResult' => [
54+
'intercept_redirects' => false,
55+
'toolbar' => false,
56+
'excluded_ajax_paths' => 'test',
57+
],
58+
],
59+
];
60+
}
61+
62+
/**
63+
* @group legacy
64+
*
65+
* @dataProvider getInterceptRedirectsConfiguration
66+
*/
67+
public function testConfigTreeUsingInterceptRedirects(bool $interceptRedirects, array $expectedResult)
68+
{
69+
$processor = new Processor();
70+
$configuration = new Configuration();
71+
$config = $processor->processConfiguration($configuration, [['intercept_redirects' => $interceptRedirects]]);
72+
73+
$this->assertEquals($expectedResult, $config);
74+
}
75+
76+
public function getInterceptRedirectsConfiguration()
77+
{
78+
return [
79+
[
80+
'interceptRedirects' => true,
81+
'expectedResult' => [
82+
'intercept_redirects' => true,
83+
'toolbar' => false,
84+
'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt',
85+
],
86+
],
87+
[
88+
'interceptRedirects' => false,
89+
'expectedResult' => [
90+
'intercept_redirects' => false,
91+
'toolbar' => false,
92+
'excluded_ajax_paths' => '^/((index|app(_[\w]+)?)\.php/)?_wdt',
93+
],
94+
],
4095
];
4196
}
4297
}

src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php

+73-8
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,21 @@ public function testDefaultConfig($debug)
9999
self::assertSaneContainer($this->getCompiledContainer());
100100
}
101101

102+
public function getDebugModes()
103+
{
104+
return [
105+
['debug' => false],
106+
['debug' => true],
107+
];
108+
}
109+
102110
/**
103-
* @dataProvider getDebugModes
111+
* @dataProvider getToolbarConfig
104112
*/
105-
public function testToolbarConfig($toolbarEnabled, $interceptRedirects, $listenerInjected, $listenerEnabled)
113+
public function testToolbarConfig(bool $toolbarEnabled, bool $listenerInjected, bool $listenerEnabled)
106114
{
107115
$extension = new WebProfilerExtension();
108-
$extension->load([['toolbar' => $toolbarEnabled, 'intercept_redirects' => $interceptRedirects]], $this->container);
116+
$extension->load([['toolbar' => $toolbarEnabled]], $this->container);
109117
$this->container->removeDefinition('web_profiler.controller.exception');
110118

111119
$this->assertSame($listenerInjected, $this->container->has('web_profiler.debug_toolbar'));
@@ -117,13 +125,70 @@ public function testToolbarConfig($toolbarEnabled, $interceptRedirects, $listene
117125
}
118126
}
119127

120-
public function getDebugModes()
128+
public function getToolbarConfig()
129+
{
130+
return [
131+
[
132+
'toolbarEnabled' => false,
133+
'listenerInjected' => false,
134+
'listenerEnabled' => false,
135+
],
136+
[
137+
'toolbarEnabled' => true,
138+
'listenerInjected' => true,
139+
'listenerEnabled' => true,
140+
],
141+
];
142+
}
143+
144+
/**
145+
* @group legacy
146+
*
147+
* @dataProvider getInterceptRedirectsToolbarConfig
148+
*/
149+
public function testToolbarConfigUsingInterceptRedirects(
150+
bool $toolbarEnabled,
151+
bool $interceptRedirects,
152+
bool $listenerInjected,
153+
bool $listenerEnabled
154+
) {
155+
$extension = new WebProfilerExtension();
156+
$extension->load(
157+
[['toolbar' => $toolbarEnabled, 'intercept_redirects' => $interceptRedirects]],
158+
$this->container
159+
);
160+
$this->container->removeDefinition('web_profiler.controller.exception');
161+
162+
$this->assertSame($listenerInjected, $this->container->has('web_profiler.debug_toolbar'));
163+
164+
self::assertSaneContainer($this->getCompiledContainer(), '', ['web_profiler.csp.handler']);
165+
166+
if ($listenerInjected) {
167+
$this->assertSame($listenerEnabled, $this->container->get('web_profiler.debug_toolbar')->isEnabled());
168+
}
169+
}
170+
171+
public function getInterceptRedirectsToolbarConfig()
121172
{
122173
return [
123-
[false, false, false, false],
124-
[true, false, true, true],
125-
[false, true, true, false],
126-
[true, true, true, true],
174+
[
175+
'toolbarEnabled' => false,
176+
'interceptRedirects' => true,
177+
'listenerInjected' => true,
178+
'listenerEnabled' => false,
179+
],
180+
[
181+
'toolbarEnabled' => false,
182+
'interceptRedirects' => false,
183+
'listenerInjected' => false,
184+
'listenerEnabled' => false,
185+
],
186+
[
187+
'toolbarEnabled' => true,
188+
'interceptRedirects' => true,
189+
'listenerInjected' => true,
190+
'listenerEnabled' => true,
191+
],
127192
];
128193
}
129194

0 commit comments

Comments
 (0)