MDL-31718 add a few more tests to check that lens and tags are properly handled

This commit is contained in:
Eloy Lafuente (stronk7) 2012-03-13 13:13:31 +01:00
parent 45c41bdc06
commit 7ca5dd85dc

View file

@ -961,12 +961,23 @@ class moodlelib_test extends UnitTestCase {
$this->assertEqual($text, shorten_text($text)); // 30 chars by default
$this->assertEqual("Žluťoučký koníče...", shorten_text($text, 19, true));
$this->assertEqual("Žluťoučký ...", shorten_text($text, 19, false));
// And try it with 2-less (that are, in bytes, the middle of a sequence)
$this->assertEqual("Žluťoučký koní...", shorten_text($text, 17, true));
$this->assertEqual("Žluťoučký ...", shorten_text($text, 17, false));
$text = "<p>Žluťoučký koníček <b>přeskočil</b> potůček</p>";
$this->assertEqual($text, shorten_text($text, 60));
$this->assertEqual("<p>Žluťoučký koníček ...</p>", shorten_text($text, 21));
$this->assertEqual("<p>Žluťoučký koníče...</p>", shorten_text($text, 19, true));
$this->assertEqual("<p>Žluťoučký ...</p>", shorten_text($text, 19, false));
// And try it with 2-less (that are, in bytes, the middle of a sequence)
$this->assertEqual("<p>Žluťoučký koní...</p>", shorten_text($text, 17, true));
$this->assertEqual("<p>Žluťoučký ...</p>", shorten_text($text, 17, false));
// And try over one tag (start/end), it does proper text len
$this->assertEqual("<p>Žluťoučký koníček <b>př...</b></p>", shorten_text($text, 23, true));
$this->assertEqual("<p>Žluťoučký koníček <b>přeskočil</b> pot...</p>", shorten_text($text, 34, true));
// And in the middle of one tag
$this->assertEqual("<p>Žluťoučký koníček <b>přeskočil...</b></p>", shorten_text($text, 30, true));
// Japanese
$text = '言語設定言語設定abcdefghijkl';
@ -1784,4 +1795,4 @@ class moodlelib_test extends UnitTestCase {
// Reset the language
$COURSE->lang = $originallang;
}
}
}