From cf9f7c6be8650329bc571e978bd8e43e5dec6560 Mon Sep 17 00:00:00 2001 From: Evgeniy Sokolov Date: Mon, 2 Feb 2015 10:38:01 +0100 Subject: [PATCH] fix error for empty type configuration --- DependencyInjection/Configuration.php | 4 ++++ .../DependencyInjection/ConfigurationTest.php | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 7ebce1b..0b01277 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -192,6 +192,10 @@ class Configuration implements ConfigurationInterface ->useAttributeAsKey('name') ->prototype('array') ->treatNullLike(array()) + ->beforeNormalization() + ->ifNull() + ->thenEmptyArray() + ->end() // BC - Renaming 'mappings' node to 'properties' ->beforeNormalization() ->ifTrue(function($v) { return array_key_exists('mappings', $v); }) diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index 7165052..30e0f7a 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -199,6 +199,24 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase $this->assertCount(3, $configuration['indexes']['test']['types']['test']['properties']); } + public function testUnconfiguredType() + { + $configuration = $this->getConfigs(array( + 'clients' => array( + 'default' => array('url' => 'http://localhost:9200'), + ), + 'indexes' => array( + 'test' => array( + 'types' => array( + 'test' => null + ) + ) + ) + )); + + $this->assertArrayHasKey('properties', $configuration['indexes']['test']['types']['test']); + } + public function testNestedProperties() { $this->getConfigs(array(