Merge branch 'w11_MDL-31718_m23_shortentext' of git://github.com/skodak/moodle
This commit is contained in:
@@ -953,6 +953,37 @@ class moodlelib_test extends UnitTestCase {
|
||||
$text = "<h1>123456789</h1>";//a string with no convenient breaks
|
||||
$this->assertEqual("<h1>12345...</h1>",
|
||||
shorten_text($text, 8));
|
||||
|
||||
// ==== this must work with UTF-8 too! ======
|
||||
|
||||
// text without tags
|
||||
$text = "Žluťoučký koníček přeskočil";
|
||||
$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));
|
||||
|
||||
$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));
|
||||
|
||||
// Japanese
|
||||
$text = '言語設定言語設定abcdefghijkl';
|
||||
$this->assertEqual($text, shorten_text($text)); // 30 chars by default
|
||||
$this->assertEqual("言語設定言語...", shorten_text($text, 9, true));
|
||||
$this->assertEqual("言語設定言語...", shorten_text($text, 9, false));
|
||||
$this->assertEqual("言語設定言語設定ab...", shorten_text($text, 13, true));
|
||||
$this->assertEqual("言語設定言語設定...", shorten_text($text, 13, false));
|
||||
|
||||
// Chinese
|
||||
$text = '简体中文简体中文abcdefghijkl';
|
||||
$this->assertEqual($text, shorten_text($text)); // 30 chars by default
|
||||
$this->assertEqual("简体中文简体...", shorten_text($text, 9, true));
|
||||
$this->assertEqual("简体中文简体...", shorten_text($text, 9, false));
|
||||
$this->assertEqual("简体中文简体中文ab...", shorten_text($text, 13, true));
|
||||
$this->assertEqual("简体中文简体中文...", shorten_text($text, 13, false));
|
||||
|
||||
}
|
||||
|
||||
function test_usergetdate() {
|
||||
|
||||
Reference in New Issue
Block a user