function TextSummaryTest::assertTextSummary

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

Calls text_summary() and asserts that the expected teaser is returned.

4 calls to TextSummaryTest::assertTextSummary()
TextSummaryTest::testFirstSentenceQuestion in core/modules/text/tests/src/Kernel/TextSummaryTest.php
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.
TextSummaryTest::testInvalidFilterFormat in core/modules/text/tests/src/Kernel/TextSummaryTest.php
Test text_summary() returns an empty string without any error when called with an invalid format.
TextSummaryTest::testLength in core/modules/text/tests/src/Kernel/TextSummaryTest.php
Test various summary length edge cases.
TextSummaryTest::testLongSentence in core/modules/text/tests/src/Kernel/TextSummaryTest.php
Test summary with long example.

File

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

Class

TextSummaryTest
Tests text_summary() with different strings and lengths.

Namespace

Drupal\Tests\text\Kernel

Code

public function assertTextSummary($text, $expected, $format = NULL, $size = NULL) {
    $summary = text_summary($text, $format, $size);
    $this->assertIdentical($summary, $expected, new FormattableMarkup('<pre style="white-space: pre-wrap">@actual</pre> is identical to <pre style="white-space: pre-wrap">@expected</pre>', [
        '@actual' => $summary,
        '@expected' => $expected,
    ]));
}

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