You are here

public function TransliterationTest::setUp in Search API 8

Overrides UnitTestCase::setUp

File

tests/src/Unit/Processor/TransliterationTest.php, line 31

Class

TransliterationTest
Tests the "Transliteration" processor.

Namespace

Drupal\Tests\search_api\Unit\Processor

Code

public function setUp() {
  parent::setUp();
  $this->index = $this
    ->createMock(IndexInterface::class);
  $this
    ->setUpMockContainer();
  $this->processor = new Transliteration([], 'transliteration', []);
  $this->processor
    ->setLangcode('en');
  $transliterator = $this
    ->createMock(TransliterationInterface::class);
  $transliterate = function ($string, $langcode = 'en', $unknown_character = '?', $max_length = NULL) {
    return "translit-{$string}-{$langcode}{$unknown_character}{$max_length}";
  };
  $transliterator
    ->expects($this
    ->any())
    ->method('transliterate')
    ->will($this
    ->returnCallback($transliterate));

  /** @var \Drupal\Component\Transliteration\TransliterationInterface $transliterator */
  $this->processor
    ->setTransliterator($transliterator);
}