public function TextSummaryTest::assertTextSummary in Drupal 9
Same name and namespace in other branches
- 8 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 - Tests 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 - 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 240
Class
- TextSummaryTest
- Tests text_summary() with different strings and lengths.
Namespace
Drupal\Tests\text\KernelCode
public function assertTextSummary($text, $expected, $format = NULL, $size = NULL) {
$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,
]));
}