public function StemmerTest::testPreprocessIndexItems in Search API 8
Tests the preprocessIndexItems() method.
@covers ::preprocessIndexItems
File
- tests/
src/ Unit/ Processor/ StemmerTest.php, line 88
Class
- StemmerTest
- Tests the "Stemmer" processor.
Namespace
Drupal\Tests\search_api\Unit\ProcessorCode
public function testPreprocessIndexItems() {
$index = $this
->createMock(IndexInterface::class);
$item_en = $this
->getMockBuilder(ItemInterface::class)
->disableOriginalConstructor()
->getMock();
$item_en
->method('getLanguage')
->willReturn('en');
$field_en = new Field($index, 'foo');
$field_en
->setType('text');
$field_en
->setValues([
new TextValue('ties'),
]);
$item_en
->method('getFields')
->willReturn([
'foo' => $field_en,
]);
$item_de = $this
->getMockBuilder(ItemInterface::class)
->disableOriginalConstructor()
->getMock();
$item_de
->method('getLanguage')
->willReturn('de');
$field_de = new Field($index, 'foo');
$field_de
->setType('text');
$field_de
->setValues([
new TextValue('ties'),
]);
$item_de
->method('getFields')
->willReturn([
'foo' => $field_de,
]);
$items = [
$item_en,
$item_de,
];
$this->processor
->preprocessIndexItems($items);
/** @var \Drupal\search_api\Plugin\search_api\data_type\value\TextValueInterface $value */
$value = $field_en
->getValues()[0];
$this
->assertEquals('tie', $value
->toText());
$value = $field_de
->getValues()[0];
$this
->assertEquals('ties', $value
->toText());
}