1 text.test | TextSummaryTestCase::testLength() |
Test various summary length edge cases.
File
- core/
modules/ field/ modules/ text/ tests/ text.test, line 424 - Tests for text.module.
Class
Code
function testLength() {
// This string tests a number of edge cases.
$text = "<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>";
// The summaries we expect text_summary() to return when $size is the index
// of each array item.
// Using no text format:
$expected = array(
"<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>",
"",
"<p></p>",
"<p></p>",
"<p>\n</p>",
"<p>\nH</p>",
"<p>\nHi</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>",
"<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>",
"<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>",
);
// And using a text format WITH the line-break and htmlcorrector filters.
$expected_lb = array(
"<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>",
"",
"<p></p>",
"<p></p>",
"<p></p>",
"<p></p>",
"<p></p>",
"<p>\nHi</p>",
"<p>\nHi</p>",
"<p>\nHi</p>",
"<p>\nHi</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>",
"<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>",
"<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>",
"<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>",
);
// Test text_summary() for different sizes.
for ($i = 0; $i <= 37; $i++) {
$this->assertTextSummary($text, $expected[$i], NULL, $i);
$this->assertTextSummary($text, $expected_lb[$i], 'filtered_html', $i);
}
}