|
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 | {
|
@@ -107,73 +105,6 @@ public function testHas()
|
107 | 105 | $this->assertFalse($bag->has('bar'), '->has() returns false if a parameter is not defined');
|
108 | 106 | }
|
109 | 107 |
|
110 |
| - public function testResolveValue() |
111 |
| - { |
112 |
| - $bag = new ParameterBag(array()); |
113 |
| - $this->assertEquals('foo', $bag->resolveValue('foo'), '->resolveValue() returns its argument unmodified if no placeholders are found'); |
114 |
| - |
115 |
| - $bag = new ParameterBag(array('foo' => 'bar')); |
116 |
| - $this->assertEquals('I\'m a bar', $bag->resolveValue('I\'m a %foo%'), '->resolveValue() replaces placeholders by their values'); |
117 |
| - $this->assertEquals(array('bar' => 'bar'), $bag->resolveValue(array('%foo%' => '%foo%')), '->resolveValue() replaces placeholders in keys and values of arrays'); |
118 |
| - $this->assertEquals(array('bar' => array('bar' => array('bar' => 'bar'))), $bag->resolveValue(array('%foo%' => array('%foo%' => array('%foo%' => '%foo%')))), '->resolveValue() replaces placeholders in nested arrays'); |
119 |
| - $this->assertEquals('I\'m a %%foo%%', $bag->resolveValue('I\'m a %%foo%%'), '->resolveValue() supports % escaping by doubling it'); |
120 |
| - $this->assertEquals('I\'m a bar %%foo bar', $bag->resolveValue('I\'m a %foo% %%foo %foo%'), '->resolveValue() supports % escaping by doubling it'); |
121 |
| - $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'); |
122 |
| - |
123 |
| - $bag = new ParameterBag(array('foo' => true)); |
124 |
| - $this->assertTrue($bag->resolveValue('%foo%'), '->resolveValue() replaces arguments that are just a placeholder by their value without casting them to strings'); |
125 |
| - $bag = new ParameterBag(array('foo' => null)); |
126 |
| - $this->assertNull($bag->resolveValue('%foo%'), '->resolveValue() replaces arguments that are just a placeholder by their value without casting them to strings'); |
127 |
| - |
128 |
| - $bag = new ParameterBag(array('foo' => 'bar', 'baz' => '%%%foo% %foo%%% %%foo%% %%%foo%%%')); |
129 |
| - $this->assertEquals('%%bar bar%% %%foo%% %%bar%%', $bag->resolveValue('%baz%'), '->resolveValue() replaces params placed besides escaped %'); |
130 |
| - |
131 |
| - $bag = new ParameterBag(array('baz' => '%%s?%%s')); |
132 |
| - $this->assertEquals('%%s?%%s', $bag->resolveValue('%baz%'), '->resolveValue() is not replacing greedily'); |
133 |
| - |
134 |
| - $bag = new ParameterBag(array()); |
135 |
| - try { |
136 |
| - $bag->resolveValue('%foobar%'); |
137 |
| - $this->fail('->resolveValue() throws an InvalidArgumentException if a placeholder references a non-existent parameter'); |
138 |
| - } catch (ParameterNotFoundException $e) { |
139 |
| - $this->assertEquals('You have requested a non-existent parameter "foobar".', $e->getMessage(), '->resolveValue() throws a ParameterNotFoundException if a placeholder references a non-existent parameter'); |
140 |
| - } |
141 |
| - |
142 |
| - try { |
143 |
| - $bag->resolveValue('foo %foobar% bar'); |
144 |
| - $this->fail('->resolveValue() throws a ParameterNotFoundException if a placeholder references a non-existent parameter'); |
145 |
| - } catch (ParameterNotFoundException $e) { |
146 |
| - $this->assertEquals('You have requested a non-existent parameter "foobar".', $e->getMessage(), '->resolveValue() throws a ParameterNotFoundException if a placeholder references a non-existent parameter'); |
147 |
| - } |
148 |
| - |
149 |
| - $bag = new ParameterBag(array('foo' => 'a %bar%', 'bar' => array())); |
150 |
| - try { |
151 |
| - $bag->resolveValue('%foo%'); |
152 |
| - $this->fail('->resolveValue() throws a RuntimeException when a parameter embeds another non-string parameter'); |
153 |
| - } catch (RuntimeException $e) { |
154 |
| - $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
10000
parameter'); |
155 |
| - } |
156 |
| - |
157 |
| - $bag = new ParameterBag(array('foo' => '%bar%', 'bar' => '%foobar%', 'foobar' => '%foo%')); |
158 |
| - try { |
159 |
| - $bag->resolveValue('%foo%'); |
160 |
| - $this->fail('->resolveValue() throws a ParameterCircularReferenceException when a parameter has a circular reference'); |
161 |
| - } catch (ParameterCircularReferenceException $e) { |
162 |
| - $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'); |
163 |
| - } |
164 |
| - |
165 |
| - $bag = new ParameterBag(array('foo' => 'a %bar%', 'bar' => 'a %foobar%', 'foobar' => 'a %foo%')); |
166 |
| - try { |
167 |
| - $bag->resolveValue('%foo%'); |
168 |
| - $this->fail('->resolveValue() throws a ParameterCircularReferenceException when a parameter has a circular reference'); |
169 |
| - } catch (ParameterCircularReferenceException $e) { |
170 |
| - $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'); |
171 |
| - } |
172 |
| - |
173 |
| - $bag = new ParameterBag(array('host' => 'foo.bar', 'port' => 1337)); |
174 |
| - $this->assertEquals('foo.bar:1337', $bag->resolveValue('%host%:%port%')); |
175 |
| - } |
176 |
| - |
177 | 108 | public function testResolveIndicatesWhyAParameterIsNeeded()
|
178 | 109 | {
|
179 | 110 | $bag = new ParameterBag(array('foo' => '%bar%'));
|
@@ -221,6 +152,7 @@ public function testEscapeValue()
|
221 | 152 |
|
222 | 153 | /**
|
223 | 154 | * @dataProvider stringsWithSpacesProvider
|
| 155 | + * @group legacy |
224 | 156 | */
|
225 | 157 | public function testResolveStringWithSpacesReturnsString($expected, $test, $description)
|
226 | 158 | {
|
|
0 commit comments