You are here

public function StemmerTest::testPreprocessMultiWordString in Snowball Stemmer 2.x

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

Tests string when more than one word sent.

Occurs when string has not been tokenized, or if there is a quoted string.

@covers ::preprocessIndexItems

File

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

Class

StemmerTest
Tests the "Stemmer" processor.

Namespace

Drupal\Tests\snowball_stemmer\Unit\Plugin\Processor

Code

public function testPreprocessMultiWordString() {
  $index = $this
    ->createMock(IndexInterface::class);
  $this->stemmerService
    ->expects($this
    ->once())
    ->method('setLanguage')
    ->with('en')
    ->willReturn(TRUE);
  $item = $this
    ->getMockBuilder(ItemInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $item
    ->method('getLanguage')
    ->willReturn('en');
  $field = new Field($index, 'foo');
  $field
    ->setType('text');
  $field
    ->setValues([
    new TextValue(" \tExtra  spaces \rappeared \n\tspaced-out  \r\n"),
  ]);
  $item
    ->method('getFields')
    ->willReturn([
    'foo' => $field,
  ]);
  $this->processor
    ->preprocessIndexItems([
    $item,
  ]);
}