Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / lib / simpletest / testweblib.php
blobaa704daaefbba7bc710d34d406005214ff52666f
1 <?php
2 /**
3 * Unit tests for (some of) ../weblib.php.
5 * @copyright &copy; 2006 The Open University
6 * @author T.J.Hunt@open.ac.uk
7 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
8 * @package moodlecore
9 */
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 {
17 function setUp() {
20 function tearDown() {
23 function test_format_string() {
24 // Ampersands
25 $this->assertEqual(format_string("& &&&&& &&"), "&amp; &amp;&amp;&amp;&amp;&amp; &amp;&amp;");
26 $this->assertEqual(format_string("ANother & &&&&& Category"), "ANother &amp; &amp;&amp;&amp;&amp;&amp; Category");
27 $this->assertEqual(format_string("ANother & &&&&& Category", true), "ANother &amp; &amp;&amp;&amp;&amp;&amp; Category");
28 $this->assertEqual(format_string("Nick's Test Site & Other things", true), "Nick's Test Site &amp; Other things");
30 // String entities
31 $this->assertEqual(format_string("&quot;"), "&quot;");
33 // Digital entities
34 $this->assertEqual(format_string("&11234;"), "&11234;");
36 // Unicode entities
37 $this->assertEqual(format_string("&#4475;"), "&#4475;");
40 function test_s() {
41 $this->assertEqual(s("This Breaks \" Strict"), "This Breaks &quot; 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>&amp; 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: &#x2022; &#8226;</p>',FORMAT_HTML));
54 $this->assertEqual($tl->code2utf8(0x7fd2).$tl->code2utf8(0x7fd2),
55 format_text_email('<p>&#x7fd2;&#x7FD2;</p>',FORMAT_HTML));