protected function SearchApiSolrLocationTest::commonSolrBackendSetUp in Search API Solr 8.3
Same name and namespace in other branches
- 8 tests/src/Kernel/SearchApiSolrLocationTest.php \Drupal\Tests\search_api_solr\Kernel\SearchApiSolrLocationTest::commonSolrBackendSetUp()
- 8.2 tests/src/Kernel/SearchApiSolrLocationTest.php \Drupal\Tests\search_api_solr\Kernel\SearchApiSolrLocationTest::commonSolrBackendSetUp()
- 4.x tests/src/Kernel/SearchApiSolrLocationTest.php \Drupal\Tests\search_api_solr\Kernel\SearchApiSolrLocationTest::commonSolrBackendSetUp()
Required parts of the setUp() function that are the same for all backends.
Overrides SolrBackendTestBase::commonSolrBackendSetUp
File
- tests/
src/ Kernel/ SearchApiSolrLocationTest.php, line 35
Class
- SearchApiSolrLocationTest
- Tests location searches and distance facets using the Solr search backend.
Namespace
Drupal\Tests\search_api_solr\KernelCode
protected function commonSolrBackendSetUp() {
$this
->installEntitySchema('field_storage_config');
$this
->installEntitySchema('field_config');
// Create a location field and storage for testing.
FieldStorageConfig::create([
'field_name' => 'location',
'entity_type' => 'entity_test_mulrev_changed',
'type' => 'geofield',
])
->save();
FieldConfig::create([
'entity_type' => 'entity_test_mulrev_changed',
'field_name' => 'location',
'bundle' => 'item',
])
->save();
$this
->insertExampleContent();
/** @var \Drupal\search_api\Entity\Index $index */
$index = Index::load($this->indexId);
$location_info = [
'datasource_id' => 'entity:entity_test_mulrev_changed',
'property_path' => 'location',
'type' => 'location',
];
$rpt_info = [
'datasource_id' => 'entity:entity_test_mulrev_changed',
'property_path' => 'location',
'type' => 'rpt',
];
$fieldsHelper = $this->container
->get('search_api.fields_helper');
// Index location coordinates as location data type.
$index
->addField($fieldsHelper
->createField($index, 'location', $location_info));
// Index location coordinates as rpt data type.
$index
->addField($fieldsHelper
->createField($index, 'rpt', $rpt_info));
$index
->save();
/** @var \Drupal\search_api\Entity\Server $server */
$server = Server::load($this->serverId);
$config = $server
->getBackendConfig();
$config['retrieve_data'] = TRUE;
$server
->setBackendConfig($config);
$server
->save();
$this
->indexItems($this->indexId);
}