Skip to content

Commit

Permalink
Allow overwriting rules in configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaeus authored and xabbuh committed Dec 22, 2018
1 parent 558b149 commit f467c32
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ private function addFormatListenerSection(ArrayNodeDefinition $rootNode)
->children()
->scalarNode('service')->defaultNull()->end()
->arrayNode('rules')
->cannotBeOverwritten()
->performNoDeepMerging()
->prototype('array')
->fixXmlConfig('priority', 'priorities')
->fixXmlConfig('attribute', 'attributes')
Expand Down
48 changes: 48 additions & 0 deletions Tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,54 @@ public function testLoadBadCodesClassThrowsException()
);
}

public function testOverwriteFormatListenerRulesDoesNotMerge()
{
$configuration = $this->processor->processConfiguration(
$this->configuration,
[
[
'format_listener' => [
'rules' => [
[
'path' => '^/admin',
'priorities' => ['html'],
],
[
'path' => '^/',
'priorities' => ['html', 'json'],
],
],
],
],
[
'format_listener' => [
'rules' => [
[
'path' => '^/',
'priorities' => ['json'],
],
],
],
],
]
);

$expected = [
[
'path' => '^/',
'priorities' => ['json'],
'host' => null,
'methods' => null,
'attributes' => [],
'stop' => false,
'prefer_extension' => true,
'fallback_format' => 'html',
],
];

$this->assertEquals($expected, $configuration['format_listener']['rules']);
}

/**
* incorrectExceptionCodeProvider.
*
Expand Down

0 comments on commit f467c32

Please sign in to comment.