Skip to content
Browse files

MDL-31718 add a few more tests to check that lens and tags are proper…

…ly handled

Conflicts:

	lib/simpletest/testmoodlelib.php
  • Loading branch information...
1 parent 6014124 commit 489981eaba1bb3f0ad8125ce2826ac59a6de2b82 @stronk7 stronk7 committed
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/simpletest/testmoodlelib.php
View
11 lib/simpletest/testmoodlelib.php
@@ -961,12 +961,23 @@ function test_shorten_text() {
$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';

0 comments on commit 489981e

Please sign in to comment.
Something went wrong with that request. Please try again.