You are here

public function SuggestionFactoryTest::testCreateFromSuggestionSuffix in Search API Autocomplete 8

Tests creating a suggestion from the suggested suffix.

@covers ::createFromSuggestionSuffix

File

tests/src/Unit/SuggestionFactoryTest.php, line 70

Class

SuggestionFactoryTest
Tests the functionality of the suggestion factory class.

Namespace

Drupal\Tests\search_api_autocomplete\Unit

Code

public function testCreateFromSuggestionSuffix() {
  $factory = new SuggestionFactory('foo');
  $suggestion = $factory
    ->createFromSuggestionSuffix('bar');
  $this
    ->assertEquals('foobar', $suggestion
    ->getSuggestedKeys());
  $this
    ->assertEquals('foo', $suggestion
    ->getUserInput());
  $this
    ->assertEquals('bar', $suggestion
    ->getSuggestionSuffix());
  $this
    ->assertNull($suggestion
    ->getLabel());
  $this
    ->assertNull($suggestion
    ->getResultsCount());
  $suggestion = $factory
    ->createFromSuggestionSuffix('o', 5);
  $this
    ->assertEquals('fooo', $suggestion
    ->getSuggestedKeys());
  $this
    ->assertEquals('foo', $suggestion
    ->getUserInput());
  $this
    ->assertEquals('o', $suggestion
    ->getSuggestionSuffix());
  $this
    ->assertNull($suggestion
    ->getLabel());
  $this
    ->assertEquals(5, $suggestion
    ->getResultsCount());
}