Skip to content

Commit cf9f7c6

Browse files
ewgRamerk
authored andcommitted
fix error for empty type configuration
1 parent 55bfee2 commit cf9f7c6

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

DependencyInjection/Configuration.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ protected function getTypesNode()
192192
->useAttributeAsKey('name')
193193
->prototype('array')
194194
->treatNullLike(array())
195+
->beforeNormalization()
196+
->ifNull()
197+
->thenEmptyArray()
198+
->end()
195199
// BC - Renaming 'mappings' node to 'properties'
196200
->beforeNormalization()
197201
->ifTrue(function($v) { return array_key_exists('mappings', $v); })

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,24 @@ public function testMappingsRenamedToProperties()
199199
$this->assertCount(3, $configuration['indexes']['test']['types']['test']['properties']);
200200
}
201201

202+
public function testUnconfiguredType()
203+
{
204+
$configuration = $this->getConfigs(array(
205+
'clients' => array(
206+
'default' => array('url' => 'http://localhost:9200'),
207+
),
208+
'indexes' => array(
209+
'test' => array(
210+
'types' => array(
211+
'test' => null
212+
)
213+
)
214+
)
215+
));
216+
217+
$this->assertArrayHasKey('properties', $configuration['indexes']['test']['types']['test']);
218+
}
219+
202220
public function testNestedProperties()
203221
{
204222
$this->getConfigs(array(

0 commit comments

Comments
 (0)