merged branch gnugat/dic-test-constants (PR #8663)
This PR was squashed before being merged into the master branch (closes #8663).
Discussion
----------
[DependencyInjection] Test constants
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | **yes**
| License | MIT
Added a test for constant support in XML configuration files.
Related PR: #8661
Commits
-------
9acedb7
[DependencyInjection] Test constants
This commit is contained in:
commit
5cbfe302c2
@ -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>
|
||||
|
@ -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');
|
||||
|
||||
|
Reference in New Issue
Block a user