class DoubleQuoteWorkaroundTest in Search API Solr 4.x
Same name and namespace in other branches
- 8.3 tests/src/Kernel/Processor/DoubleQuoteWorkaroundTest.php \Drupal\Tests\search_api_solr\Kernel\Processor\DoubleQuoteWorkaroundTest
- 8.2 tests/src/Kernel/Processor/DoubleQuoteWorkaroundTest.php \Drupal\Tests\search_api_solr\Kernel\Processor\DoubleQuoteWorkaroundTest
Tests the "Double Quote Workaround" processor.
@group search_api_solr
Hierarchy
- class \Drupal\Tests\search_api_solr\Kernel\Processor\DoubleQuoteWorkaroundTest extends \Drupal\Tests\search_api\Kernel\Processor\ProcessorTestBase uses SolrBackendTrait
Expanded class hierarchy of DoubleQuoteWorkaroundTest
See also
\Drupal\search_api_solr\Plugin\search_api\processor\DoubleQuoteWorkaround
File
- tests/
src/ Kernel/ Processor/ DoubleQuoteWorkaroundTest.php, line 14
Namespace
Drupal\Tests\search_api_solr\Kernel\ProcessorView source
class DoubleQuoteWorkaroundTest extends ProcessorTestBase {
use SolrBackendTrait;
/**
* The nodes created for testing.
*
* @var \Drupal\node\Entity\Node[]
*/
protected $nodes;
/**
* {@inheritdoc}
*/
public static $modules = [
'search_api_solr',
'search_api_solr_test',
];
/**
* {@inheritdoc}
*/
public function setUp($processor = NULL) : void {
parent::setUp('double_quote_workaround');
$this
->enableSolrServer();
$backend = $this->index
->getServerInstance()
->getBackend();
$config = $backend
->getConfiguration();
// Streaming expressions are only supported by Solr Cloud.
$config['connector'] = 'solr_cloud';
$backend
->setConfiguration($config);
$this->queryHelper = \Drupal::getContainer()
->get('search_api_solr.streaming_expression_query_helper');
$this->query = $this->queryHelper
->createQuery($this->index);
$this->exp = $this->queryHelper
->getStreamingExpressionBuilder($this->query);
}
/**
* Tests double quote workaround.
*/
public function testDoubleQuoteWorkaround() {
$processor = $this->index
->getProcessor('double_quote_workaround');
$configuration = $processor
->getConfiguration();
$replacement = $configuration['replacement'];
$this
->assertEquals('|9999999998|', $replacement);
// Set fields to process.
$configuration['fields'] = [
'title',
];
$processor
->setConfiguration($configuration);
$this->index
->setProcessors([
'double_quote_workaround' => $processor,
]);
$this->index
->save();
$streaming_expression = $this->exp
->search($this->exp
->_collection(), 'q=' . $this->exp
->_field_escaped_value('search_api_datasource', 'entity:entity_test_mulrev_changed'), 'fq="' . $this->exp
->_field_escaped_value('title', 'double "quotes" within the text', FALSE) . '"', 'fl="' . $this->exp
->_field('title') . '"', 'sort="' . $this->exp
->_field('search_api_id') . ' DESC"', 'qt="/export"');
$this
->assertEquals('search(drupal, q=ss_search_api_datasource:entity\\:entity_test_mulrev_changed, fq="tm_X3b_und_title:\\"double ' . $replacement . 'quotes' . $replacement . ' within the text\\"", fl="tm_X3b_und_title", sort="ss_search_api_id DESC", qt="/export")', $streaming_expression);
$this
->assertEquals('double "quotes" within the text', $this->processor
->decodeStreamingExpressionValue('double ' . $replacement . 'quotes' . $replacement . ' within the text'));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DoubleQuoteWorkaroundTest:: |
public static | property | ||
DoubleQuoteWorkaroundTest:: |
protected | property | The nodes created for testing. | |
DoubleQuoteWorkaroundTest:: |
public | function | ||
DoubleQuoteWorkaroundTest:: |
public | function | Tests double quote workaround. | |
SolrBackendTrait:: |
protected | function | Swap the DB backend for a Solr backend. | 3 |
SolrBackendTrait:: |
protected | function | ||
SolrBackendTrait:: |
protected | function | ||
SolrCommitTrait:: |
protected | function | Explicitly sends a commit command to a Solr server. |