class SolrLegacyTest in Search API Solr 4.x
Tests index and search capabilities using the Solr search backend.
@group search_api_solr_legacy
Hierarchy
- class \Drupal\Tests\search_api_solr\Kernel\SolrBackendTestBase extends \Drupal\Tests\search_api\Kernel\BackendTestBase uses SolrCommitTrait
- class \Drupal\Tests\search_api_solr\Kernel\SearchApiSolrTest uses SolrCommitTrait, InvokeMethodTrait
- class \Drupal\Tests\search_api_solr_legacy\Kernel\SolrLegacyTest
- class \Drupal\Tests\search_api_solr\Kernel\SearchApiSolrTest uses SolrCommitTrait, InvokeMethodTrait
Expanded class hierarchy of SolrLegacyTest
File
- modules/
search_api_solr_legacy/ tests/ src/ Kernel/ SolrLegacyTest.php, line 15
Namespace
Drupal\Tests\search_api_solr_legacy\KernelView source
class SolrLegacyTest extends SearchApiSolrTest {
/**
* {@inheritdoc}
*/
public static $modules = [
'search_api_solr_legacy',
'search_api_solr_legacy_test',
];
/**
* {@inheritdoc}
*/
protected function installConfigs() {
parent::installConfigs();
$this
->installConfig([
'search_api_solr_legacy',
'search_api_solr_legacy_test',
]);
// Swap the connector.
Solr36TestConnector::adjustBackendConfig('search_api.server.solr_search_server');
}
/**
* Tests the conversion of Search API queries into Solr queries.
*/
protected function checkSchemaLanguages() {
// Solr 3.6 doesn't provide the required REST API.
}
/**
* Test generation of Solr configuration files.
*
* @dataProvider configGenerationDataProvider
*
* @throws \Drupal\search_api\SearchApiException
* @throws \Drupal\Core\Entity\EntityStorageException
*/
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']);
}
/**
* Data provider for testConfigGeneration method.
*/
public function configGenerationDataProvider() {
// @codingStandardsIgnoreStart
return [
[
[
'schema.xml' => [
# phonetic is currently not available for Solr <= 7.x.
#'fieldType name="text_phonetic_en" class="solr.TextField"',
'fieldType name="text_en" class="solr.TextField"',
'fieldType name="text_de" class="solr.TextField"',
'<fieldType name="text_foo_en" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.LengthFilterFactory" min="2" max="100"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.LengthFilterFactory" min="2" max="100"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>',
'<dynamicField name="ts_X3b_en_*" type="text_en" stored="true" indexed="true" multiValued="false" termVectors="true" omitNorms="false" />',
'<dynamicField name="tm_X3b_en_*" type="text_en" stored="true" indexed="true" multiValued="true" termVectors="true" omitNorms="false" />',
'<dynamicField name="tos_X3b_en_*" type="text_en" stored="true" indexed="true" multiValued="false" termVectors="true" omitNorms="true" />',
'<dynamicField name="tom_X3b_en_*" type="text_en" stored="true" indexed="true" multiValued="true" termVectors="true" omitNorms="true" />',
'<dynamicField name="tus_X3b_en_*" type="text_unstemmed_en" stored="true" indexed="true" multiValued="false" termVectors="true" omitNorms="false" />',
'<dynamicField name="tum_X3b_en_*" type="text_unstemmed_en" stored="true" indexed="true" multiValued="true" termVectors="true" omitNorms="false" />',
'<dynamicField name="ts_X3b_und_*" type="text_und" stored="true" indexed="true" multiValued="false" termVectors="true" omitNorms="false" />',
'<dynamicField name="tm_X3b_und_*" type="text_und" stored="true" indexed="true" multiValued="true" termVectors="true" omitNorms="false" />',
'<dynamicField name="tos_X3b_und_*" type="text_und" stored="true" indexed="true" multiValued="false" termVectors="true" omitNorms="true" />',
'<dynamicField name="tom_X3b_und_*" type="text_und" stored="true" indexed="true" multiValued="true" termVectors="true" omitNorms="true" />',
'<dynamicField name="tus_X3b_und_*" type="text_und" stored="true" indexed="true" multiValued="false" termVectors="true" omitNorms="false" />',
'<dynamicField name="tum_X3b_und_*" type="text_und" stored="true" indexed="true" multiValued="true" termVectors="true" omitNorms="false" />',
'<dynamicField name="tus_*" type="text_und" stored="true" indexed="true" multiValued="false" termVectors="true" omitNorms="false" />',
'<dynamicField name="tum_*" type="text_und" stored="true" indexed="true" multiValued="true" termVectors="true" omitNorms="false" />',
'<dynamicField name="ts_X3b_de_*" type="text_de" stored="true" indexed="true" multiValued="false" termVectors="true" omitNorms="false" />',
'<dynamicField name="tm_X3b_de_*" type="text_de" stored="true" indexed="true" multiValued="true" termVectors="true" omitNorms="false" />',
'<dynamicField name="tos_X3b_de_*" type="text_de" stored="true" indexed="true" multiValued="false" termVectors="true" omitNorms="true" />',
'<dynamicField name="tom_X3b_de_*" type="text_de" stored="true" indexed="true" multiValued="true" termVectors="true" omitNorms="true" />',
'<dynamicField name="tus_X3b_de_*" type="text_unstemmed_de" stored="true" indexed="true" multiValued="false" termVectors="true" omitNorms="false" />',
'<dynamicField name="tum_X3b_de_*" type="text_unstemmed_de" stored="true" indexed="true" multiValued="true" termVectors="true" omitNorms="false" />',
'<dynamicField name="spellcheck_und*" type="text_spell_und" stored="true" indexed="true" multiValued="true" termVectors="true" omitNorms="true" />',
'<dynamicField name="spellcheck_*" type="text_spell_und" stored="true" indexed="true" multiValued="true" termVectors="true" omitNorms="true" />',
],
'solrconfig.xml' => [
'<str name="name">en</str>',
'<str name="name">de</str>',
],
'stopwords_en.txt' => [],
'synonyms_en.txt' => [
'drupal, durpal',
],
'protwords_en.txt' => [],
'accents_en.txt' => [
'"\\u00C4" => "A"',
],
'stopwords_de.txt' => [],
'synonyms_de.txt' => [
'drupal, durpal',
],
'protwords_de.txt' => [],
'accents_de.txt' => [
' Not needed if German2 Porter stemmer is used.',
],
'elevate.xml' => [],
'test.txt' => [
'hook_search_api_solr_config_files_alter() works',
],
],
],
];
// @codingStandardsIgnoreEnd
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
InvokeMethodTrait:: |
protected | function | Calls protected/private method of a class. | |
SearchApiSolrTest:: |
protected | property | The fields helper. | |
SearchApiSolrTest:: |
protected | property | ||
SearchApiSolrTest:: |
protected | function | ||
SearchApiSolrTest:: |
protected | function | ||
SearchApiSolrTest:: |
protected | function | Checks backend specific features. | |
SearchApiSolrTest:: |
protected | function | Test that basic auth config gets passed to Solarium. | |
SearchApiSolrTest:: |
protected | function | Tests addition and deletion of a data source. | |
SearchApiSolrTest:: |
protected | function | Tests highlight options. | |
SearchApiSolrTest:: |
protected | function | Tests retrieve_data options. | |
SearchApiSolrTest:: |
protected | function |
Overrides SolrBackendTestBase:: |
|
SearchApiSolrTest:: |
protected | function | Tests the conversion of Search API queries into Solr queries. | |
SearchApiSolrTest:: |
protected | function | Tests the conversion of Search API queries into Solr queries. | |
SearchApiSolrTest:: |
protected | function | Tests retrieve_data options. | |
SearchApiSolrTest:: |
public | function | Tests search result grouping. | |
SearchApiSolrTest:: |
protected | function | Tests search result sorts. | |
SearchApiSolrTest:: |
protected | function |
Required parts of the setUp() function that are the same for all backends. Overrides SolrBackendTestBase:: |
|
SearchApiSolrTest:: |
protected | function | Return the expected facets for regression test 2469547. | |
SearchApiSolrTest:: |
protected | function | If the list of entity ids contains language codes it will be handled here, otherwise it will be handed over to the parent implementation. | |
SearchApiSolrTest:: |
protected | function | Produces a string of given comprising diverse chars. | |
SearchApiSolrTest:: |
protected | function | Tests index prefix. | |
SearchApiSolrTest:: |
protected | function | Creates several test entities. | |
SearchApiSolrTest:: |
protected | function | Regression tests for #2469547. | |
SearchApiSolrTest:: |
protected | function | Regression tests for #2888629. | |
SearchApiSolrTest:: |
public | function | ||
SearchApiSolrTest:: |
public | function | Tests the autocomplete support and ngram results. | |
SearchApiSolrTest:: |
public | function | Tests language fallback and language limiting via options. | |
SolrBackendTestBase:: |
protected | property | A Search API index ID. | 1 |
SolrBackendTestBase:: |
protected | property | The in-memory logger. | |
SolrBackendTestBase:: |
protected | property | A Search API server ID. | 1 |
SolrBackendTestBase:: |
protected | function | Tests the last logged level and message. | |
SolrBackendTestBase:: |
protected | function | ||
SolrBackendTestBase:: |
protected | function | ||
SolrBackendTestBase:: |
protected | function | ||
SolrBackendTestBase:: |
protected | function | ||
SolrBackendTestBase:: |
protected | function | Executes a query and skips search_api post processing of results. | |
SolrBackendTestBase:: |
protected | function | Gets the Solr version. | |
SolrBackendTestBase:: |
protected | function | ||
SolrBackendTestBase:: |
public | function | ||
SolrBackendTestBase:: |
public | function | Clear the index after every test. | |
SolrBackendTestBase:: |
protected | function | ||
SolrCommitTrait:: |
protected | function | Explicitly sends a commit command to a Solr server. | |
SolrLegacyTest:: |
public static | property |
Modules to enable for this test. Overrides SearchApiSolrTest:: |
|
SolrLegacyTest:: |
protected | function |
Tests the conversion of Search API queries into Solr queries. Overrides SearchApiSolrTest:: |
|
SolrLegacyTest:: |
public | function |
Data provider for testConfigGeneration method. Overrides SearchApiSolrTest:: |
|
SolrLegacyTest:: |
protected | function |
Called by setUp() to install required configs. Overrides SearchApiSolrTest:: |
|
SolrLegacyTest:: |
public | function |
Test generation of Solr configuration files. Overrides SearchApiSolrTest:: |