3 * Unit tests for (some of) ../weblib.php.
5 * @copyright © 2006 The Open University
6 * @author T.J.Hunt@open.ac.uk
7 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
11 if (!defined('MOODLE_INTERNAL')) {
12 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
15 class web_test
extends UnitTestCase
{
23 function test_format_string() {
25 $this->assertEqual(format_string("& &&&&& &&"), "& &&&&& &&");
26 $this->assertEqual(format_string("ANother & &&&&& Category"), "ANother & &&&&& Category");
27 $this->assertEqual(format_string("ANother & &&&&& Category", true), "ANother & &&&&& Category");
28 $this->assertEqual(format_string("Nick's Test Site & Other things", true), "Nick's Test Site & Other things");
31 $this->assertEqual(format_string("""), """);
34 $this->assertEqual(format_string("&11234;"), "&11234;");
37 $this->assertEqual(format_string("ᅻ"), "ᅻ");
41 $this->assertEqual(s("This Breaks \" Strict"), "This Breaks " Strict");
44 function test_format_text_email() {
45 $this->assertEqual('This is a test',
46 format_text_email('<p>This is a <strong>test</strong></p>',FORMAT_HTML
));
47 $this->assertEqual('This is a test',
48 format_text_email('<p class="frogs">This is a <strong class=\'fishes\'>test</strong></p>',FORMAT_HTML
));
49 $this->assertEqual('& so is this',
50 format_text_email('<p>& so is this</p>',FORMAT_HTML
));
51 $tl = textlib_get_instance();
52 $this->assertEqual('Two bullets: '.$tl->code2utf8(8226).' '.$tl->code2utf8(8226),
53 format_text_email('<p>Two bullets: • •</p>',FORMAT_HTML
));
54 $this->assertEqual($tl->code2utf8(0x7fd2).$tl->code2utf8(0x7fd2),
55 format_text_email('<p>習習</p>',FORMAT_HTML
));