Skip to content

Commit

Permalink
MDL-31718 add a few more tests to check that lens and tags are proper…
Browse files Browse the repository at this point in the history
…ly handled

Conflicts:

	lib/simpletest/testmoodlelib.php
  • Loading branch information
stronk7 committed Mar 13, 2012
1 parent 6014124 commit 489981e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/simpletest/testmoodlelib.php
Expand Up @@ -961,12 +961,23 @@ function test_shorten_text() {
$this->assertEqual($text, shorten_text($text)); // 30 chars by default $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ý koníče...", shorten_text($text, 19, true));
$this->assertEqual("Žluťoučký ...", shorten_text($text, 19, false)); $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>"; $text = "<p>Žluťoučký koníček <b>přeskočil</b> potůček</p>";
$this->assertEqual($text, shorten_text($text, 60)); $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íč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ý koníče...</p>", shorten_text($text, 19, true));
$this->assertEqual("<p>Žluťoučký ...</p>", shorten_text($text, 19, false)); $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 // Japanese
$text = '言語設定言語設定abcdefghijkl'; $text = '言語設定言語設定abcdefghijkl';
Expand Down

0 comments on commit 489981e

Please sign in to comment.