function TextSummaryTest::testFirstSentenceQuestion

Same name and namespace in other branches
  1. 9 core/modules/text/tests/src/Kernel/TextSummaryTest.php \Drupal\Tests\text\Kernel\TextSummaryTest::testFirstSentenceQuestion()
  2. 10 core/modules/text/tests/src/Kernel/TextSummaryTest.php \Drupal\Tests\text\Kernel\TextSummaryTest::testFirstSentenceQuestion()
  3. 11.x core/modules/text/tests/src/Kernel/TextSummaryTest.php \Drupal\Tests\text\Kernel\TextSummaryTest::testFirstSentenceQuestion()

Tests an edge case where the first sentence is a question and subsequent sentences are not. This edge case is documented at https://www.drupal.org/node/180425.

File

core/modules/text/tests/src/Kernel/TextSummaryTest.php, line 43

Class

TextSummaryTest
Tests <a href="/api/drupal/core%21modules%21text%21text.module/function/text_summary/8.9.x" title="Generates a trimmed, formatted version of a text field value." class="local">text_summary</a>() with different strings and lengths.

Namespace

Drupal\Tests\text\Kernel

Code

public function testFirstSentenceQuestion() {
    $text = 'A question? A sentence. Another sentence.';
    $expected = 'A question? A sentence.';
    $this->assertTextSummary($text, $expected, NULL, 30);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.