minor #18500 [DependencyInjection] Add coverage for all invalid arguments in exportParameters (JhonnyL)

This PR was merged into the 2.3 branch.

Discussion
----------

[DependencyInjection] Add coverage for all invalid arguments in exportParameters

| Q             | A
| ------------- | ---
| Branch?       | 2.3
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

Commits
-------

87c4f23 [DependencyInjection] Add coverage for all invalid arguments in exportParameters
This commit is contained in:
Fabien Potencier 2016-04-11 05:47:06 -07:00
commit 302e1928b8
1 changed files with 13 additions and 2 deletions

View File

@ -16,6 +16,7 @@ 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;
class PhpDumperTest extends \PHPUnit_Framework_TestCase
{
@ -100,14 +101,24 @@ 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 Reference('foo'))),
array(array('foo' => new Variable('foo'))),
);
}
public function testAddParameters()
{
$container = include self::$fixturesPath.'/containers/container8.php';