[DependencyInjection] Test constants

This commit is contained in:
Loïc Chardonnet 2013-08-04 11:31:43 +02:00 committed by Fabien Potencier
parent 5ea5921918
commit 9acedb7227
2 changed files with 46 additions and 2 deletions

View File

@ -27,5 +27,6 @@
<parameter key="MixedCase" type="collection"> <!-- Should be lower cased -->
<parameter key="MixedCaseKey">value</parameter> <!-- Should stay mixed case -->
</parameter>
<parameter key="constant" type="constant">PHP_EOL</parameter>
</parameters>
</container>

View File

@ -99,7 +99,27 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
$loader->load('services2.xml');
$actual = $container->getParameterBag()->all();
$expected = array('a string', 'foo' => 'bar', 'values' => array(0, 'integer' => 4, 100 => null, 'true', true, false, 'on', 'off', 'float' => 1.3, 1000.3, 'a string', array('foo', 'bar')), 'foo_bar' => new Reference('foo_bar'), 'mixedcase' => array('MixedCaseKey' => 'value'));
$expected = array(
'a string',
'foo' => 'bar',
'values' => array(
0,
'integer' => 4,
100 => null,
'true',
true,
false,
'on',
'off',
'float' => 1.3,
1000.3,
'a string',
array('foo', 'bar'),
),
'foo_bar' => new Reference('foo_bar'),
'mixedcase' => array('MixedCaseKey' => 'value'),
'constant' => PHP_EOL,
);
$this->assertEquals($expected, $actual, '->load() converts XML values to PHP ones');
}
@ -120,7 +140,30 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
$loader->load('services4.xml');
$actual = $container->getParameterBag()->all();
$expected = array('a string', 'foo' => 'bar', 'values' => array(true, false), 'foo_bar' => new Reference('foo_bar'), 'mixedcase' => array('MixedCaseKey' => 'value'), 'bar' => '%foo%', 'imported_from_ini' => true, 'imported_from_yaml' => true);
$expected = array(
'a string',
'foo' => 'bar',
'values' => array(
0,
'integer' => 4,
100 => null,
'true',
true,
false,
'on',
'off',
'float' => 1.3,
1000.3,
'a string',
array('foo', 'bar'),
),
'foo_bar' => new Reference('foo_bar'),
'mixedcase' => array('MixedCaseKey' => 'value'),
'constant' => PHP_EOL,
'bar' => '%foo%',
'imported_from_ini' => true,
'imported_from_yaml' => true
);
$this->assertEquals(array_keys($expected), array_keys($actual), '->load() imports and merges imported files');