|
13 | 13 |
|
14 | 14 | use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
15 | 15 | use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
|
16 |
| -use Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException; |
17 |
| -use Symfony\Component\DependencyInjection\Exception\RuntimeException; |
18 | 16 |
|
19 | 17 | class ParameterBagTest extends \PHPUnit_Framework_TestCase
|
20 | 18 | {
|
@@ -112,73 +110,6 @@ public function testHas()
|
112 | 110 | $this->assertFalse($bag->has('bar'), '->has() returns false if a parameter is not defined');
|
113 | 111 | }
|
114 | 112 |
|
115 |
| - public function testResolveValue() |
116 |
| - { |
117 |
| - $bag = new ParameterBag(array()); |
118 |
| - $this->assertEquals('foo', $bag->resolveValue('foo'), '->resolveValue() returns its argument unmodified if no placeholders are found'); |
119 |
| - |
120 |
| - $bag = new ParameterBag(array('foo' => 'bar')); |
121 |
| - $this->assertEquals('I\'m a bar', $bag->resolveValue('I\'m a %foo%'), '->resolveValue() replaces placeholders by their values'); |
122 |
| - $this->assertEquals(array('bar' => 'bar'), $bag->resolveValue(array('%foo%' => '%foo%')), '->resolveValue() replaces placeholders in keys and values of arrays'); |
123 |
| - $this->assertEquals(array('bar' => array('bar' => array('bar' => 'bar'))), $bag->resolveValue(array('%foo%' => array('%foo%' => array('%foo%' => '%foo%')))), '->resolveValue() replaces placeholders in nested arrays'); |
124 |
| - $this->assertEquals('I\'m a %%foo%%', $bag->resolveValue('I\'m a %%foo%%'), '->resolveValue() supports % escaping by doubling it'); |
125 |
| - $this->assertEquals('I\'m a bar %%foo bar', $bag->resolveValue('I\'m a %foo% %%foo %foo%'), '->resolveValue() supports % escaping by doubling it'); |
126 |
| - $this->assertEquals(array('foo' => array('bar' => array('ding' => 'I\'m a bar %%foo %%bar'))), $bag->resolveValue(array('foo' => array('bar' => array('ding' => 'I\'m a bar %%foo %%bar')))), '->resolveValue() supports % escaping by doubling it'); |
127 |
| - |
128 |
| - $bag = new ParameterBag(array('foo' => true)); |
129 |
| - $this->assertTrue($bag->resolveValue('%foo%'), '->resolveValue() replaces arguments that are just a placeholder by their value without casting them to strings'); |
130 |
| - $bag = new ParameterBag(array('foo' => null)); |
131 |
| - $this->assertNull($bag->resolveValue('%foo%'), '->resolveValue() replaces arguments that are just a placeholder by their value without casting them to strings'); |
132 |
| - |
133 |
| - $bag = new ParameterBag(array('foo' => 'bar', 'baz' => '%%%foo% %foo%%% %%foo%% %%%foo%%%')); |
134 |
| - $this->assertEquals('%%bar bar%% %%foo%% %%bar%%', $bag->resolveValue('%baz%'), '->resolveValue() replaces params placed besides escaped %'); |
135 |
| - |
136 |
| - $bag = new ParameterBag(array('baz' => '%%s?%%s')); |
137 |
| - $this->assertEquals('%%s?%%s', $bag->resolveValue('%baz%'), '->resolveValue() is not replacing greedily'); |
138 |
| - |
139 |
| - $bag = new ParameterBag(array()); |
140 |
| - try { |
141 |
| - $bag->resolveValue('%foobar%'); |
142 |
| - $this->fail('->resolveValue() throws an InvalidArgumentException if a placeholder references a non-existent parameter'); |
143 |
| - } catch (ParameterNotFoundException $e) { |
144 |
| - $this->assertEquals('You have requested a non-existent parameter "foobar".', $e->getMessage(), '->resolveValue() throws a ParameterNotFoundException if a placeholder references a non-existent parameter'); |
145 |
| - } |
146 |
| - |
147 |
| - try { |
148 |
| - $bag->resolveValue('foo %foobar% bar'); |
149 |
| - $this->fail('->resolveValue() throws a ParameterNotFoundException if a placeholder references a non-existent parameter'); |
150 |
| - } catch (ParameterNotFoundException $e) { |
151 |
| - $this->assertEquals('You have requested a non-existent parameter "foobar".', $e->getMessage(), '->resolveValue() throws a ParameterNotFoundException if a placeholder references a non-existent parameter'); |
152 |
| - } |
153 |
| - |
154 |
| - $bag = new ParameterBag(array('foo' => 'a %bar%', 'bar' => array())); |
155 |
| - try { |
156 |
| - $bag->resolveValue('%foo%'); |
157 |
| - $this->fail('->resolveValue() throws a RuntimeException when a parameter embeds another non-string parameter'); |
158 |
| - } catch (RuntimeException $e) { |
159 |
| - $this->assertEquals('A string value must be composed of strings and/or numbers, but found parameter "bar" of type array inside string value "a %bar%".', $e->getMessage(), '->resolveValue() throws a RuntimeException when a parameter embeds another non-string parameter'); |
160 |
| - } |
161 |
| - |
162 |
| - $bag = new ParameterBag(array('foo' => '%bar%', 'bar' => '%foobar%', 'foobar' => '%foo%')); |
163 |
| - try { |
164 |
| - $bag->resolveValue('%foo%'); |
165 |
| - $this->fail('->resolveValue() throws a ParameterCircularReferenceException when a parameter has a circular reference'); |
166 |
| - } catch (ParameterCircularReferenceException $e) { |
167 |
| - $this->assertEquals('Circular reference detected for parameter "foo" ("foo" > "bar" > "foobar" > "foo").', $e->getMessage(), '->resolveValue() throws a ParameterCircularReferenceException when a parameter has a circular reference'); |
168 |
| - } |
169 |
| - |
170 |
| - $bag = new ParameterBag(array('foo' => 'a %bar%', 'bar' => 'a %foobar%', 'foobar' => 'a %foo%')); |
171 |
| - try { |
172 |
| - $bag->resolveValue('%foo%'); |
173 |
| - $this->fail('->resolveValue() throws a ParameterCircularReferenceException when a parameter has a circular reference'); |
174 |
| - } catch (ParameterCircularReferenceException $e) { |
175 |
| - $this->assertEquals('Circular reference detected for parameter "foo" ("foo" > "bar" > "foobar" > "foo").', $e->getMessage(), '->resolveValue() throws a ParameterCircularReferenceException when a parameter has a circular reference'); |
176 |
| - } |
177 |
| - |
178 |
| - $bag = new ParameterBag(array('host' => 'foo.bar', 'port' => 1337)); |
179 |
| - $this->assertEquals('foo.bar:1337', $bag->resolveValue('%host%:%port%')); |
180 |
| - } |
181 |
| - |
182 | 113 | public function testResolveIndicatesWhyAParameterIsNeeded()
|
183 | 114 | {
|
184 | 115 | $bag = new ParameterBag(array('foo' => '%bar%'));
|
@@ -226,6 +157,7 @@ public function testEscapeValue()
|
226 | 157 |
|
227 | 158 | /**
|
228 | 159 | * @dataProvider stringsWithSpacesProvider
|
| 160 | + * @group legacy |
229 | 161 | */
|
230 | 162 | public function testResolveStringWithSpacesReturnsString($expected, $test, $description)
|
231 | 163 | {
|
|
0 commit comments