public function StopwordsTest::testPreprocessSearchQuery in Search API 8
Tests the processor's preprocessSearchQuery() method.
File
- tests/
src/ Unit/ Processor/ StopwordsTest.php, line 95
Class
- StopwordsTest
- Tests the "Stopwords" processor.
Namespace
Drupal\Tests\search_api\Unit\ProcessorCode
public function testPreprocessSearchQuery() {
$index = $this
->createMock(IndexInterface::class);
$index
->expects($this
->any())
->method('status')
->will($this
->returnValue(TRUE));
/** @var \Drupal\search_api\IndexInterface $index */
$this->processor
->setIndex($index);
$query = \Drupal::getContainer()
->get('search_api.query_helper')
->createQuery($index);
$keys = [
'#conjunction' => 'AND',
'foo',
'bar',
'bar foo',
];
$query
->keys($keys);
$configuration = [
'stopwords' => [
'foobar',
'bar',
'barfoo',
],
];
$this->processor
->setConfiguration($configuration);
$this->processor
->preprocessSearchQuery($query);
unset($keys[1]);
$this
->assertEquals($keys, $query
->getKeys());
$this
->assertEquals([
'bar',
], $query
->getResults()
->getIgnoredSearchKeys());
}