public function SolrLegacyTest::testConfigGeneration in Search API Solr 4.x
Test generation of Solr configuration files.
@dataProvider configGenerationDataProvider
Throws
\Drupal\search_api\SearchApiException
\Drupal\Core\Entity\EntityStorageException
Overrides SearchApiSolrTest::testConfigGeneration
File
- modules/
search_api_solr_legacy/ tests/ src/ Kernel/ SolrLegacyTest.php, line 55
Class
- SolrLegacyTest
- Tests index and search capabilities using the Solr search backend.
Namespace
Drupal\Tests\search_api_solr_legacy\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.xml']);
$this
->assertStringContainsString('solr.luceneMatchVersion=' . $solr_major_version, $config_files['solrcore.properties']);
$this
->assertStringNotContainsString('<statsCache', $config_files['solrconfig.xml']);
$backend_config['connector_config']['jmx'] = TRUE;
$backend_config['disabled_field_types'] = [
'text_foo_en_3_6_0',
'text_foo_en_4_5_0',
'text_foo_en_6_0_0',
'text_de_3_6_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.xml']);
$this
->assertStringContainsString('text_en', $config_files['schema.xml']);
$this
->assertStringNotContainsString('text_foo_en', $config_files['schema.xml']);
$this
->assertStringNotContainsString('text_de', $config_files['schema.xml']);
$this
->assertStringContainsString('httpCaching', $config_files['solrconfig.xml']);
$this
->assertStringContainsString('never304="true"', $config_files['solrconfig.xml']);
$this
->assertStringContainsString('ts_X3b_en_*', $config_files['schema.xml']);
$this
->assertStringNotContainsString('ts_X3b_de_*', $config_files['schema.xml']);
/** @var \Drupal\search_api_solr\SolrBackendInterface $backend */
$backend = $server
->getBackend();
$this
->assertStringContainsString('solr.install.dir', $config_files['solrcore.properties']);
$this
->assertStringContainsString('solr.replication', $config_files['solrcore.properties']);
$this
->assertStringContainsString('"/replication"', $config_files['solrconfig.xml']);
}