public function StemmerTest::testPreprocessSearchQueryNoLanguage in Snowball Stemmer 2.x
Same name and namespace in other branches
- 8 tests/src/Unit/Plugin/Processor/StemmerTest.php \Drupal\Tests\snowball_stemmer\Unit\Plugin\Processor\StemmerTest::testPreprocessSearchQueryNoLanguage()
Tests preprocessSearchQuery() method with no language.
@covers ::preprocessIndexItems
File
- tests/
src/ Unit/ Plugin/ Processor/ StemmerTest.php, line 243
Class
- StemmerTest
- Tests the "Stemmer" processor.
Namespace
Drupal\Tests\snowball_stemmer\Unit\Plugin\ProcessorCode
public function testPreprocessSearchQueryNoLanguage() {
$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);
$language = $this
->createMock(LanguageInterface::class);
$language
->expects($this
->any())
->method('getId')
->will($this
->returnValue('xxx'));
$this->languageManager
->expects($this
->any())
->method('getCurrentLanguage')
->will($this
->returnValue($language));
$this->stemmerService
->expects($this
->once())
->method('setLanguage')
->with('xxx')
->will($this
->returnValue(FALSE));
$this->stemmerService
->expects($this
->never())
->method('stem');
$query = \Drupal::getContainer()
->get('search_api.query_helper')
->createQuery($index);
$keys = [
'#conjunction' => 'AND',
'foo',
'bar',
'bar foo',
];
$query
->keys($keys);
$this->processor
->preprocessSearchQuery($query);
}