function TextSummaryTest::assertTextSummary

Same name in other branches
  1. 8.9.x 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.

@internal

4 calls to TextSummaryTest::assertTextSummary()
TextSummaryTest::testFirstSentenceQuestion in core/modules/text/tests/src/Kernel/TextSummaryTest.php
Tests text summaries for a question followed by a sentence.
TextSummaryTest::testInvalidFilterFormat in core/modules/text/tests/src/Kernel/TextSummaryTest.php
Tests text summaries with an invalid filter format.
TextSummaryTest::testLength in core/modules/text/tests/src/Kernel/TextSummaryTest.php
Tests various summary length edge cases.
TextSummaryTest::testLongSentence in core/modules/text/tests/src/Kernel/TextSummaryTest.php
Tests summary with long example.

File

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

Class

TextSummaryTest
Tests text_summary() with different strings and lengths.

Namespace

Drupal\Tests\text\Kernel

Code

public function assertTextSummary(string $text, string $expected, ?string $format = NULL, int $size = NULL) : void {
    $summary = text_summary($text, $format, $size);
    $this->assertSame($expected, $summary, 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.