You are here

public function StemmerTest::testPreprocessUnknownLanguage 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::testPreprocessUnknownLanguage()

Tests string when language unknown.

@covers ::preprocessIndexItems

File

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

Class

StemmerTest
Tests the "Stemmer" processor.

Namespace

Drupal\Tests\snowball_stemmer\Unit\Plugin\Processor

Code

public function testPreprocessUnknownLanguage() {
  $index = $this
    ->createMock(IndexInterface::class);
  $this->stemmerService
    ->expects($this
    ->once())
    ->method('setLanguage')
    ->with('xx')
    ->willReturn(FALSE);
  $this->stemmerService
    ->expects($this
    ->never())
    ->method('stem');
  $item = $this
    ->getMockBuilder(ItemInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $item
    ->method('getLanguage')
    ->willReturn('xx');
  $field = new Field($index, 'foo');
  $field
    ->setType('text');
  $field
    ->setValues([
    new TextValue('Anything.'),
  ]);
  $item
    ->method('getFields')
    ->willReturn([
    'foo' => $field,
  ]);
  $this->processor
    ->preprocessIndexItems([
    $item,
  ]);
}