trait SolrBackendTrait in Search API Solr 8.2
Same name and namespace in other branches
- 8.3 tests/src/Kernel/Processor/SolrBackendTrait.php \Drupal\Tests\search_api_solr\Kernel\Processor\SolrBackendTrait
- 8 tests/src/Kernel/Processor/SolrBackendTrait.php \Drupal\Tests\search_api_solr\Kernel\Processor\SolrBackendTrait
- 4.x tests/src/Kernel/Processor/SolrBackendTrait.php \Drupal\Tests\search_api_solr\Kernel\Processor\SolrBackendTrait
Helper to exchange the DB backend for a Solr backend in processor tests.
Hierarchy
- trait \Drupal\Tests\search_api_solr\Kernel\Processor\SolrBackendTrait uses SolrCommitTrait
File
- tests/
src/ Kernel/ Processor/ SolrBackendTrait.php, line 12
Namespace
Drupal\Tests\search_api_solr\Kernel\ProcessorView source
trait SolrBackendTrait {
use SolrCommitTrait;
/**
* Swap the DB backend for a Solr backend.
*
* This function has to be called from the test setUp() function.
*
* @param string $module
* The module that provides the server config.
* @param $config
* The server config
*/
protected function enableSolrServer($module, $config) {
$this->server = Server::create(Yaml::parse(file_get_contents(drupal_get_path('module', $module) . $config)));
$this->server
->save();
$this->index
->setServer($this->server);
$this->index
->save();
$index_storage = $this->container
->get('entity_type.manager')
->getStorage('search_api_index');
$index_storage
->resetCache([
$this->index
->id(),
]);
$this->index = $index_storage
->load($this->index
->id());
}
/**
* {@inheritdoc}
*/
protected function indexItems() {
$index_status = parent::indexItems();
$this
->ensureCommit($this->server);
return $index_status;
}
/**
* {@inheritdoc}
*/
protected function tearDown() {
$this->index
->clear();
$this
->ensureCommit($this->server);
parent::tearDown();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SolrBackendTrait:: |
protected | function | Swap the DB backend for a Solr backend. | |
SolrBackendTrait:: |
protected | function | ||
SolrBackendTrait:: |
protected | function | ||
SolrCommitTrait:: |
protected | function | Explicitly sent a commit command to a Solr server. |