public function DoubleQuoteWorkaroundTest::testDoubleQuoteWorkaround in Search API Solr 8.2
Same name and namespace in other branches
- 8.3 tests/src/Kernel/Processor/DoubleQuoteWorkaroundTest.php \Drupal\Tests\search_api_solr\Kernel\Processor\DoubleQuoteWorkaroundTest::testDoubleQuoteWorkaround()
- 4.x tests/src/Kernel/Processor/DoubleQuoteWorkaroundTest.php \Drupal\Tests\search_api_solr\Kernel\Processor\DoubleQuoteWorkaroundTest::testDoubleQuoteWorkaround()
Tests double quote workaround.
File
- tests/
src/ Kernel/ Processor/ DoubleQuoteWorkaroundTest.php, line 53
Class
- DoubleQuoteWorkaroundTest
- Tests the "Double Quote Workaround" processor.
Namespace
Drupal\Tests\search_api_solr\Kernel\ProcessorCode
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(d8, q=ss_search_api_datasource:entity\\:entity_test_mulrev_changed, fq="tm_title:\\"double ' . $replacement . 'quotes' . $replacement . ' within the text\\"", fl="tm_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'));
}