You are here

public function StemmerTest::testPreprocessIndexItems in Snowball Stemmer 8

Same name and namespace in other branches
  1. 2.x tests/src/Unit/Plugin/Processor/StemmerTest.php \Drupal\Tests\snowball_stemmer\Unit\Plugin\Processor\StemmerTest::testPreprocessIndexItems()

Tests language set of preprocessIndexItems() method.

@covers ::preprocessIndexItems

File

tests/src/Unit/Plugin/Processor/StemmerTest.php, line 59

Class

StemmerTest
Tests the "Stemmer" processor.

Namespace

Drupal\Tests\snowball_stemmer\Unit\Plugin\Processor

Code

public function testPreprocessIndexItems() {
  $index = $this
    ->createMock(IndexInterface::class);
  $this->stemmerService
    ->expects($this
    ->once())
    ->method('setLanguage')
    ->with('en')
    ->willReturn(TRUE);
  $this->stemmerService
    ->expects($this
    ->once())
    ->method('stem')
    ->with('backing')
    ->willReturn('back');
  $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('backing'),
  ]);
  $item_en
    ->method('getFields')
    ->willReturn([
    'foo' => $field_en,
  ]);
  $this->processor
    ->preprocessIndexItems([
    $item_en,
  ]);
}