[SecurityBundle] Added a validation rule
This enforces to configure each provider in exactly one way.
This commit is contained in:
parent
b107a3fdf0
commit
9e41ff4db5
@ -325,8 +325,7 @@ class MainConfiguration implements ConfigurationInterface
|
||||
|
||||
$factory->addConfiguration($factoryNode);
|
||||
}
|
||||
/*
|
||||
* TODO find a way to do the validation. Issue appears because of prototyped nodes
|
||||
|
||||
$providerNodeBuilder
|
||||
->validate()
|
||||
->ifTrue(function($v){return count($v) > 1;})
|
||||
@ -337,7 +336,6 @@ class MainConfiguration implements ConfigurationInterface
|
||||
->thenInvalid('You must set a provider definition for the provider.')
|
||||
->end()
|
||||
;
|
||||
*/
|
||||
}
|
||||
|
||||
private function addEncodersSection(ArrayNodeDefinition $rootNode)
|
||||
|
@ -24,7 +24,9 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
protected static $minimalConfig = array(
|
||||
'providers' => array(
|
||||
'stub' => array(),
|
||||
'stub' => array(
|
||||
'id' => 'foo',
|
||||
),
|
||||
),
|
||||
'firewalls' => array(
|
||||
'stub' => array(),
|
||||
@ -49,4 +51,39 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertFalse(array_key_exists('factory', $config), 'The factory key is silently removed without an exception');
|
||||
$this->assertEquals(array(), $config['factories'], 'The factories key is just an empty array');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||
*/
|
||||
public function testNoConfigForProvider()
|
||||
{
|
||||
$config = array(
|
||||
'providers' => array(
|
||||
'stub' => array(),
|
||||
),
|
||||
);
|
||||
|
||||
$processor = new Processor();
|
||||
$configuration = new MainConfiguration(array(), array());
|
||||
$config = $processor->processConfiguration($configuration, array($config));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||
*/
|
||||
public function testManyConfigForProvider()
|
||||
{
|
||||
$config = array(
|
||||
'providers' => array(
|
||||
'stub' => array(
|
||||
'id' => 'foo',
|
||||
'chain' => array(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$processor = new Processor();
|
||||
$configuration = new MainConfiguration(array(), array());
|
||||
$config = $processor->processConfiguration($configuration, array($config));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user