You are here

protected function SearchExcerptTest::doSearchExcerpt in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/search/src/Tests/SearchExcerptTest.php \Drupal\search\Tests\SearchExcerptTest::doSearchExcerpt()

Calls search_excerpt() and renders output.

Parameters

string $keys: A string containing a search query.

string $render_array: The text to extract fragments from.

string|null $langcode: Language code for the language of $text, if known.

Return value

string A string containing HTML for the excerpt.

2 calls to SearchExcerptTest::doSearchExcerpt()
SearchExcerptTest::testSearchExcerpt in core/modules/search/src/Tests/SearchExcerptTest.php
Tests search_excerpt() with several simulated search keywords.
SearchExcerptTest::testSearchExcerptSimplified in core/modules/search/src/Tests/SearchExcerptTest.php
Tests search_excerpt() with search keywords matching simplified words.

File

core/modules/search/src/Tests/SearchExcerptTest.php, line 196
Contains \Drupal\search\Tests\SearchExcerptTest.

Class

SearchExcerptTest
Tests the search_excerpt() function.

Namespace

Drupal\search\Tests

Code

protected function doSearchExcerpt($keys, $render_array, $langcode = NULL) {
  $render_array = search_excerpt($keys, $render_array, $langcode);
  $text = \Drupal::service('renderer')
    ->renderPlain($render_array);

  // The search_excerpt() function adds some extra spaces -- not
  // important for HTML formatting or this test. Remove these for comparison.
  return preg_replace('| +|', ' ', $text);
}