Skip to content

Commit 208cc1b

Browse files
committed
[DependencyInjection] Add coverage for invalid Expression in exportParameters
1 parent df33bfe commit 208cc1b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Tests/Dumper/PhpDumperTest.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
1717
use Symfony\Component\DependencyInjection\Reference;
1818
use Symfony\Component\DependencyInjection\Definition;
19+
use Symfony\Component\DependencyInjection\Variable;
20+
use Symfony\Component\ExpressionLanguage\Expression;
1921

2022
class PhpDumperTest extends \PHPUnit_Framework_TestCase
2123
{
@@ -85,14 +87,25 @@ public function testDumpRelativeDir()
8587
}
8688

8789
/**
90+
* @dataProvider provideInvalidParameters
8891
* @expectedException \InvalidArgumentException
8992
*/
90-
public function testExportParameters()
93+
public function testExportParameters($parameters)
9194
{
92-
$dumper = new PhpDumper(new ContainerBuilder(new ParameterBag(array('foo' => new Reference('foo')))));
95+
$dumper = new PhpDumper(new ContainerBuilder(new ParameterBag($parameters)));
9396
$dumper->dump();
9497
}
9598

99+
public function provideInvalidParameters()
100+
{
101+
return array(
102+
array(array('foo' => new Definition('stdClass'))),
103+
array(array('foo' => new Expression('service("foo").foo() ~ (container.hasparameter("foo") ? parameter("foo") : "default")'))),
104+
array(array('foo' => new Reference('foo'))),
105+
array(array('foo' => new Variable('foo'))),
106+
);
107+
}
108+
96109
public function testAddParameters()
97110
{
98111
$container = include self::$fixturesPath.'/containers/container8.php';

0 commit comments

Comments
 (0)