From 1931b14a607208148adc288c0ebd57092a58cb60 Mon Sep 17 00:00:00 2001 From: JhonnyL Date: Sun, 10 Apr 2016 20:38:01 +0200 Subject: [PATCH] [DependencyInjection] Add coverage for invalid Expression in exportParameters --- .../Tests/Dumper/PhpDumperTest.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 7207a143e6..afe2f10ff5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -16,6 +16,8 @@ use Symfony\Component\DependencyInjection\Dumper\PhpDumper; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\Variable; +use Symfony\Component\ExpressionLanguage\Expression; class PhpDumperTest extends \PHPUnit_Framework_TestCase { @@ -85,14 +87,25 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase } /** + * @dataProvider provideInvalidParameters * @expectedException \InvalidArgumentException */ - public function testExportParameters() + public function testExportParameters($parameters) { - $dumper = new PhpDumper(new ContainerBuilder(new ParameterBag(array('foo' => new Reference('foo'))))); + $dumper = new PhpDumper(new ContainerBuilder(new ParameterBag($parameters))); $dumper->dump(); } + public function provideInvalidParameters() + { + return array( + array(array('foo' => new Definition('stdClass'))), + array(array('foo' => new Expression('service("foo").foo() ~ (container.hasparameter("foo") ? parameter("foo") : "default")'))), + array(array('foo' => new Reference('foo'))), + array(array('foo' => new Variable('foo'))), + ); + } + public function testAddParameters() { $container = include self::$fixturesPath.'/containers/container8.php';