public function SuggestionFactoryTest::testCreateUrlSuggestion in Search API Autocomplete 8
Tests creating a URL suggestion.
@covers ::createUrlSuggestion
File
- tests/
src/ Unit/ SuggestionFactoryTest.php, line 93
Class
- SuggestionFactoryTest
- Tests the functionality of the suggestion factory class.
Namespace
Drupal\Tests\search_api_autocomplete\UnitCode
public function testCreateUrlSuggestion() {
$factory = new SuggestionFactory('foo');
/** @var \Drupal\Core\Url $url */
$url = $this
->getMockBuilder(Url::class)
->disableOriginalConstructor()
->getMock();
$suggestion = $factory
->createUrlSuggestion($url, 'Foobar');
$this
->assertSame($url, $suggestion
->getUrl());
$this
->assertNull($suggestion
->getSuggestedKeys());
$this
->assertNull($suggestion
->getUserInput());
$this
->assertEquals('Foobar', $suggestion
->getLabel());
$this
->assertNull($suggestion
->getResultsCount());
$this
->assertNull($suggestion
->getRender());
$render = [
'foo' => 'bar',
];
$suggestion = $factory
->createUrlSuggestion($url, NULL, $render);
$this
->assertSame($url, $suggestion
->getUrl());
$this
->assertNull($suggestion
->getSuggestedKeys());
$this
->assertNull($suggestion
->getUserInput());
$this
->assertNull($suggestion
->getLabel());
$this
->assertNull($suggestion
->getResultsCount());
$this
->assertEquals($render, $suggestion
->getRender());
}