Fix ClassCastException when no settings are present

This commit is contained in:
Tim Nagel 2014-06-26 17:29:16 +10:00
parent ffa73db1d2
commit a879d3c1c9
3 changed files with 32 additions and 3 deletions

View file

@ -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;
}

View file

@ -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

View file

@ -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'