xref: /dokuwiki/_test/tests/inc/utf8_html.test.php (revision 5398a7b652eabdd0a20f154b97b60f89cad72f8c)
1<?php
2
3// use no mbstring help here
4if(!defined('UTF8_NOMBSTRING')) define('UTF8_NOMBSTRING',1);
5
6class utf8_html_test extends DokuWikiTest {
7
8    function test_from_1byte(){
9        $in  = 'a';
10        $out = 'a';
11        $this->assertEquals(utf8_tohtml($in),$out);
12    }
13
14    function test_from_2byte(){
15        $in  = "\xc3\xbc";
16        $out = '&#252;';
17        $this->assertEquals(utf8_tohtml($in),$out);
18    }
19
20    function test_from_3byte(){
21        $in  = "\xe2\x99\x8a";
22        $out = '&#x264a;';
23        $this->assertEquals(utf8_tohtml($in),$out);
24    }
25
26    function test_from_4byte(){
27        $in  = "\xf4\x80\x80\x81";
28        $out = '&#x100001;';
29        $this->assertEquals(utf8_tohtml($in),$out);
30    }
31
32    function test_to_1byte(){
33        $out  = 'a';
34        $in = 'a';
35        $this->assertEquals(utf8_unhtml($in),$out);
36    }
37
38    function test_to_2byte(){
39        $out  = "\xc3\xbc";
40        $in = '&#252;';
41        $this->assertEquals(utf8_unhtml($in),$out);
42    }
43
44    function test_to_3byte(){
45        $out  = "\xe2\x99\x8a";
46        $in = '&#x264a;';
47        $this->assertEquals(utf8_unhtml($in),$out);
48    }
49
50    function test_to_4byte(){
51        $out  = "\xf4\x80\x80\x81";
52        $in = '&#x100001;';
53        $this->assertEquals(utf8_unhtml($in),$out);
54    }
55
56    function test_without_entities(){
57        $out  = '&amp;#38;&amp;#38;';
58        $in = '&amp;#38;&#38;amp;#38;';
59        $this->assertEquals(utf8_unhtml($in),$out);
60    }
61
62    function test_with_entities(){
63        $out  = '&#38;&amp;#38;';
64        $in = '&amp;#38;&#38;amp;#38;';
65        $this->assertEquals(utf8_unhtml($in,HTML_ENTITIES),$out);
66    }
67
68}
69
70//Setup VIM: ex: et ts=4 :
71