public function SearchApiSolrTest::testConfigGeneration in Search API Solr 4.x
Same name and namespace in other branches
- 8.3 tests/src/Kernel/SearchApiSolrTest.php \Drupal\Tests\search_api_solr\Kernel\SearchApiSolrTest::testConfigGeneration()
- 8.2 tests/src/Kernel/SearchApiSolrTest.php \Drupal\Tests\search_api_solr\Kernel\SearchApiSolrTest::testConfigGeneration()
Test generation of Solr configuration files.
@dataProvider configGenerationDataProvider
Throws
\Drupal\search_api\SearchApiException
\Drupal\Core\Entity\EntityStorageException
1 method overrides SearchApiSolrTest::testConfigGeneration()
- SolrLegacyTest::testConfigGeneration in modules/
search_api_solr_legacy/ tests/ src/ Kernel/ SolrLegacyTest.php - Test generation of Solr configuration files.
File
- tests/
src/ Kernel/ SearchApiSolrTest.php, line 1454
Class
- SearchApiSolrTest
- Tests index and search capabilities using the Solr search backend.
Namespace
Drupal\Tests\search_api_solr\KernelCode
public function testConfigGeneration(array $files) {
$server = $this
->getServer();
$solr_major_version = $server
->getBackend()
->getSolrConnector()
->getSolrMajorVersion();
$backend_config = $server
->getBackendConfig();
$solr_configset_controller = new SolrConfigSetController();
$solr_configset_controller
->setServer($server);
$config_files = $solr_configset_controller
->getConfigFiles();
foreach ($files as $file_name => $expected_strings) {
$this
->assertArrayHasKey($file_name, $config_files);
foreach ($expected_strings as $string) {
$this
->assertStringContainsString($string, $config_files[$file_name]);
}
}
$config_name = 'name="drupal-' . SolrBackendInterface::SEARCH_API_SOLR_SCHEMA_VERSION . '-solr-' . $solr_major_version . '.x-' . SEARCH_API_SOLR_JUMP_START_CONFIG_SET . '"';
$this
->assertStringContainsString($config_name, $config_files['solrconfig.xml']);
$this
->assertStringContainsString($config_name, $config_files['schema.xml']);
$this
->assertStringContainsString($server
->id(), $config_files['test.txt']);
$this
->assertStringNotContainsString('<jmx />', $config_files['solrconfig_extra.xml']);
$this
->assertStringNotContainsString('JtsSpatialContextFactory', $config_files['schema.xml']);
if ('true' === SOLR_CLOUD) {
$this
->assertStringContainsString('solr.luceneMatchVersion:' . $solr_major_version, $config_files['solrconfig.xml']);
$this
->assertStringContainsString('<statsCache class="org.apache.solr.search.stats.LRUStatsCache" />', $config_files['solrconfig_extra.xml']);
}
else {
$this
->assertStringContainsString('solr.luceneMatchVersion=' . $solr_major_version, $config_files['solrcore.properties']);
$this
->assertStringNotContainsString('<statsCache', $config_files['solrconfig_extra.xml']);
}
$backend_config['connector_config']['jmx'] = TRUE;
$backend_config['connector_config']['jts'] = TRUE;
$backend_config['disabled_field_types'] = [
'text_foo_en_4_5_0',
'text_foo_en_6_0_0',
'text_de_4_5_0',
'text_de_6_0_0',
'text_de_7_0_0',
];
$backend_config['disabled_caches'] = [
'cache_document_default_7_0_0',
'cache_filter_default_7_0_0',
];
$server
->setBackendConfig($backend_config);
$server
->save();
// Reset static caches.
$solr_configset_controller
->setServer($server);
$config_files = $solr_configset_controller
->getConfigFiles();
$this
->assertStringContainsString('<jmx />', $config_files['solrconfig_extra.xml']);
$this
->assertStringContainsString('JtsSpatialContextFactory', $config_files['schema.xml']);
$this
->assertStringContainsString('text_en', $config_files['schema_extra_types.xml']);
$this
->assertStringNotContainsString('text_foo_en', $config_files['schema_extra_types.xml']);
$this
->assertStringNotContainsString('text_de', $config_files['schema_extra_types.xml']);
if (version_compare($solr_major_version, '7', '>=')) {
$this
->assertStringNotContainsString('documentCache', $config_files['solrconfig_query.xml']);
$this
->assertStringNotContainsString('filterCache', $config_files['solrconfig_query.xml']);
$this
->assertStringContainsString('httpCaching', $config_files['solrconfig_requestdispatcher.xml']);
$this
->assertStringContainsString('never304="true"', $config_files['solrconfig_requestdispatcher.xml']);
}
else {
$this
->assertStringContainsString('httpCaching', $config_files['solrconfig.xml']);
$this
->assertStringContainsString('never304="true"', $config_files['solrconfig.xml']);
}
$this
->assertStringContainsString('ts_X3b_en_*', $config_files['schema_extra_fields.xml']);
$this
->assertStringNotContainsString('ts_X3b_de_*', $config_files['schema_extra_fields.xml']);
/** @var \Drupal\search_api_solr\SolrBackendInterface $backend */
$backend = $server
->getBackend();
if ($backend
->getSolrConnector()
->isCloud()) {
$this
->assertArrayNotHasKey('solrcore.properties', $config_files);
$this
->assertStringNotContainsString('"/replication"', $config_files['solrconfig_extra.xml']);
$this
->assertStringNotContainsString('"/get"', $config_files['solrconfig_extra.xml']);
}
else {
$this
->assertStringNotContainsString('solr.install.dir', $config_files['solrcore.properties']);
$this
->assertStringContainsString('solr.replication', $config_files['solrcore.properties']);
$this
->assertStringContainsString('"/replication"', $config_files[version_compare($solr_major_version, '7', '>=') ? 'solrconfig_extra.xml' : 'solrconfig.xml']);
if (version_compare($solr_major_version, '7', '>=')) {
$this
->assertStringNotContainsString('"/get"', $config_files['solrconfig_extra.xml']);
}
else {
$this
->assertStringContainsString('"/get"', $config_files['solrconfig.xml']);
}
}
}