Don’t normalize global values

This commit is contained in:
Lars Strojny 2018-04-03 14:46:42 +02:00
parent 8c4fd1299b
commit 8c1672743d
2 changed files with 25 additions and 0 deletions

View File

@ -76,6 +76,7 @@ class Configuration implements ConfigurationInterface
->useAttributeAsKey('key')
->example(array('foo' => '"@bar"', 'pi' => 3.14))
->prototype('array')
->normalizeKeys(false)
->beforeNormalization()
->ifTrue(function ($v) { return is_string($v) && 0 === strpos($v, '@'); })
->then(function ($v) {

View File

@ -41,4 +41,28 @@ class ConfigurationTest extends TestCase
$this->assertFalse($config['strict_variables']);
}
public function testGlobalsAreNotNormalized()
{
$input = array(
'globals' => array('some-global' => true),
);
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(), array($input));
$this->assertSame(array('some-global' => array('value' => true)), $config['globals']);
}
public function testArrayKeysInGlobalsAreNotNormalized()
{
$input = array(
'globals' => array('global' => array('some-key' => 'some-value')),
);
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(), array($input));
$this->assertSame(array('global' => array('value' => array('some-key' => 'some-value'))), $config['globals']);
}
}