xref: /dokuwiki/_test/tests/inc/auth_nameencode.test.php (revision ead851a84b96ca8b022e8980362b248ec2712dfa)
1<?php
2
3class auth_nameencode_test extends DokuWikiTest {
4
5    function tearDown() {
6        global $cache_authname;
7        $cache_authname = array();
8    }
9
10    function test_simple(){
11        $in  = 'hey$you';
12        $out = 'hey%24you';
13        $this->assertEquals(auth_nameencode($in),$out);
14    }
15
16    function test_quote(){
17        $in  = 'hey"you';
18        $out = 'hey%22you';
19        $this->assertEquals(auth_nameencode($in),$out);
20    }
21
22    function test_apostrophe(){
23        $in  = 'hey\'you';
24        $out = 'hey%27you';
25        $this->assertEquals(auth_nameencode($in),$out);
26    }
27
28    function test_backslash(){
29        $in  = 'hey\\you';
30        $out = 'hey%5cyou';
31        $this->assertEquals(auth_nameencode($in),$out);
32    }
33
34    function test_complex(){
35        $in  = 'hey $ you !$%! foo ';
36        $out = 'hey%20%24%20you%20%21%24%25%21%20foo%20';
37        $this->assertEquals(auth_nameencode($in),$out);
38    }
39
40    function test_complexutf8(){
41        $in  = 'häü $ yü !$%! foo ';
42        $out = 'häü%20%24%20yü%20%21%24%25%21%20foo%20';
43        $this->assertEquals(auth_nameencode($in),$out);
44    }
45
46    function test_groupskipon(){
47        $in  = '@hey$you';
48        $out = '@hey%24you';
49        $this->assertEquals(auth_nameencode($in,true),$out);
50    }
51
52    function test_groupskipoff(){
53        $in  = '@hey$you';
54        $out = '%40hey%24you';
55        $this->assertEquals(auth_nameencode($in),$out);
56    }
57
58    // include a two byte utf8 character which shouldn't be encoded
59    function test_hebrew(){
60        $in = 'nun-נ8';
61        $expect = 'nun%2dנ8';
62
63        $this->assertEquals($expect, auth_nameencode($in));
64    }
65
66    // include a three byte utf8 character which shouldn't be encoded
67    function test_devanagiri(){
68        $in = 'ut-fठ8';
69        $expect = 'ut%2dfठ8';
70
71        $this->assertEquals($expect, auth_nameencode($in));
72    }
73}
74
75//Setup VIM: ex: et ts=4 :
76