public function ViewsTest::testHighlighting in Search API 8
Checks whether highlighting of results works correctly.
See also
views.view.search_api_test_cache.yml
File
- tests/
src/ Functional/ ViewsTest.php, line 1126
Class
- ViewsTest
- Tests the Views integration of the Search API.
Namespace
Drupal\Tests\search_api\FunctionalCode
public function testHighlighting() {
// Add the Highlight processor to the search index.
$index = Index::load('database_search_index');
$processor = \Drupal::getContainer()
->get('search_api.plugin_helper')
->createProcessorPlugin($index, 'highlight');
$index
->addProcessor($processor);
$index
->save();
$path = 'search-api-test-search-view-caching-none';
$this
->drupalGet($path);
$this
->assertSession()
->responseContains('foo bar baz');
$options['query']['search_api_fulltext'] = 'foo';
$this
->drupalGet($path, $options);
$this
->assertSession()
->responseContains('<strong>foo</strong> bar baz');
$options['query']['search_api_fulltext'] = 'bar';
$this
->drupalGet($path, $options);
$this
->assertSession()
->responseContains('foo <strong>bar</strong> baz');
}