/**
  * @dataProvider getSetRootNameData
  * @param string $name
  * @param array $configArray
  * @param string $resultStartsWith
  */
 public function testSetRootName($name, $configArray, $resultStartsWith)
 {
     $indexConfig = new IndexConfig($name, array(), $configArray);
     $index = $this->getMockBuilder('FOS\\ElasticaBundle\\Elastica\\Index')->disableOriginalConstructor()->getMock();
     $index->expects($this->once())->method('overrideName')->with($this->stringStartsWith($resultStartsWith));
     $this->processor->setRootName($indexConfig, $index);
 }
 /**
  * Deletes and recreates the named index. If populating, creates a new index
  * with a randomised name for an alias to be set after population.
  *
  * @param string $indexName
  * @param bool $populating
  * @throws \InvalidArgumentException if no index exists for the given name
  */
 public function resetIndex($indexName, $populating = false)
 {
     $indexConfig = $this->configManager->getIndexConfiguration($indexName);
     $index = $this->indexManager->getIndex($indexName);
     if ($indexConfig->isUseAlias()) {
         $this->aliasProcessor->setRootName($indexConfig, $index);
     }
     $mapping = $this->mappingBuilder->buildIndexMapping($indexConfig);
     $index->create($mapping, true);
     if (!$populating and $indexConfig->isUseAlias()) {
         $this->aliasProcessor->switchIndexAlias($indexConfig, $index);
     }
 }
 /**
  * Deletes and recreates the named index. If populating, creates a new index
  * with a randomised name for an alias to be set after population.
  *
  * @param string $indexName
  * @param bool   $populating
  * @param bool   $force      If index exists with same name as alias, remove it
  *
  * @throws \InvalidArgumentException if no index exists for the given name
  */
 public function resetIndex($indexName, $populating = false, $force = false)
 {
     $indexConfig = $this->configManager->getIndexConfiguration($indexName);
     $index = $this->indexManager->getIndex($indexName);
     $event = new IndexResetEvent($indexName, $populating, $force);
     $this->dispatcher->dispatch(IndexResetEvent::PRE_INDEX_RESET, $event);
     if ($indexConfig->isUseAlias()) {
         $this->aliasProcessor->setRootName($indexConfig, $index);
     }
     $mapping = $this->mappingBuilder->buildIndexMapping($indexConfig);
     $index->create($mapping, true);
     if (!$populating and $indexConfig->isUseAlias()) {
         $this->aliasProcessor->switchIndexAlias($indexConfig, $index, $force);
     }
     $this->dispatcher->dispatch(IndexResetEvent::POST_INDEX_RESET, $event);
 }