From 99011ca9c9b0eb6f55f5a9fe679a647b158d3ed1 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Tue, 27 Dec 2011 12:48:49 -0800 Subject: [PATCH] Added tests for ParameterBag parameters with spaces --- .../ParameterBag/ParameterBagTest.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/Symfony/Tests/Component/DependencyInjection/ParameterBag/ParameterBagTest.php b/tests/Symfony/Tests/Component/DependencyInjection/ParameterBag/ParameterBagTest.php index f453ba5c7120..1499927f8c4d 100644 --- a/tests/Symfony/Tests/Component/DependencyInjection/ParameterBag/ParameterBagTest.php +++ b/tests/Symfony/Tests/Component/DependencyInjection/ParameterBag/ParameterBagTest.php @@ -164,4 +164,29 @@ public function testResolveIndicatesWhyAParameterIsNeeded() $this->assertEquals('The parameter "foo" has a dependency on a non-existent parameter "bar".', $e->getMessage()); } } + + /** + * @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::resolve + * @dataProvider stringsWithSpacesProvider + */ + public function testResolveStringWithSpacesReturnsString($expected, $test, $description) + { + $bag = new ParameterBag(array('foo' => 'bar')); + + try { + $this->assertEquals($expected, $bag->resolveString($test), $description); + } catch (ParameterNotFoundException $e) { + $this->fail(sprintf('%s - "%s"', $description, $expected)); + } + } + + public function stringsWithSpacesProvider() + { + return array( + array('bar', '%foo%', 'Parameters must be wrapped by %.'), + array('% foo %', '% foo %', 'Parameters should not have spaces.'), + array('{% set my_template = "foo" %}', '{% set my_template = "foo" %}', 'Twig-like strings are not parameters.'), + array('50% is less than 100%', '50% is less than 100%', 'Text between % signs is allowed, if there are spaces.'), + ); + } }