Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use Symfony\Component\Config\Definition\Builder\TreeBuilder;
- use Symfony\Component\Config\Definition\ConfigurationInterface;
- use Symfony\Component\Config\Definition\Processor;
- class ConfigurationTest extends \PHPUnit_Framework_TestCase
- {
- public function testProcessConfiguration()
- {
- $configs = [
- [
- 'array1' => [
- 'key1' => [
- 'array2' => []
- ],
- 'key2' => [
- 'array3' => []
- ]
- ]
- ]
- ];
- $processor = new Processor();
- $config = $processor->processConfiguration(new Configuration(), $configs);
- $this->assertArrayHasKey('array1', $config);
- $this->assertEquals($configs[0]['array1'], $config['array1']);
- }
- }
- class Configuration implements ConfigurationInterface
- {
- public function getConfigTreeBuilder()
- {
- $treeBuilder = new TreeBuilder();
- $rootNode = $treeBuilder->root('root');
- $rootNode
- ->children()
- ->arrayNode('array1')
- ->useAttributeAsKey('name')
- ->prototype('array')
- ->children()
- ->arrayNode('array2')
- ->prototype('variable')->end()
- // ->children()->end()
- ->end()
- ->arrayNode('array3')
- ->prototype('variable')->end()
- // ->children()->end()
- ->end()
- ->end()
- ->end()
- ;
- return $treeBuilder;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement