Fix ClassCastException when no settings are present
This commit is contained in:
parent
ffa73db1d2
commit
a879d3c1c9
|
@ -31,10 +31,14 @@ class MappingBuilder
|
|||
|
||||
$mapping = array(
|
||||
'mappings' => $typeMappings,
|
||||
'settings' => $indexConfig->getSettings(),
|
||||
// 'warmers' => $indexConfig->getWarmers(),
|
||||
);
|
||||
|
||||
$settings = $indexConfig->getSettings();
|
||||
if ($settings) {
|
||||
$mapping['settings'] = $settings;
|
||||
}
|
||||
|
||||
return $mapping;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,30 @@ class MappingToElasticaTest extends WebTestCase
|
|||
$this->assertNotEmpty($mapping, 'Mapping was populated');
|
||||
}
|
||||
|
||||
public function testORMResetIndexAddsMappings()
|
||||
{
|
||||
$client = $this->createClient(array('test_case' => 'ORM'));
|
||||
$resetter = $this->getResetter($client);
|
||||
$resetter->resetIndex('index');
|
||||
|
||||
$type = $this->getType($client);
|
||||
$mapping = $type->getMapping();
|
||||
|
||||
$this->assertNotEmpty($mapping, 'Mapping was populated');
|
||||
}
|
||||
|
||||
public function testORMResetType()
|
||||
{
|
||||
$client = $this->createClient(array('test_case' => 'ORM'));
|
||||
$resetter = $this->getResetter($client);
|
||||
$resetter->resetIndexType('index', 'type');
|
||||
|
||||
$type = $this->getType($client);
|
||||
$mapping = $type->getMapping();
|
||||
|
||||
$this->assertNotEmpty($mapping, 'Mapping was populated');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Client $client
|
||||
* @return \FOS\ElasticaBundle\Resetter $resetter
|
||||
|
|
|
@ -43,11 +43,12 @@ fos_elastica:
|
|||
listener:
|
||||
is_indexable_callback: 'object.isntIndexable()'
|
||||
type3:
|
||||
properties:
|
||||
mappings:
|
||||
field1: ~
|
||||
persistence:
|
||||
driver: orm
|
||||
model: FOS\ElasticaBundle\Tests\Functional\TypeObj
|
||||
finder: ~
|
||||
provider: ~
|
||||
listener:
|
||||
is_indexable_callback: 'isntIndexable'
|
||||
|
||||
|
|
Loading…
Reference in a new issue