xref: /dokuwiki/_test/tests/inc/auth_nameencode.test.php (revision 698e7df8c9d5c43a93ed6822efa537158682a700)
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_complex(){
23        $in  = 'hey $ you !$%! foo ';
24        $out = 'hey%20%24%20you%20%21%24%25%21%20foo%20';
25        $this->assertEquals(auth_nameencode($in),$out);
26    }
27
28    function test_complexutf8(){
29        $in  = 'häü $ yü !$%! foo ';
30        $out = 'häü%20%24%20yü%20%21%24%25%21%20foo%20';
31        $this->assertEquals(auth_nameencode($in),$out);
32    }
33
34    function test_groupskipon(){
35        $in  = '@hey$you';
36        $out = '@hey%24you';
37        $this->assertEquals(auth_nameencode($in,true),$out);
38    }
39
40    function test_groupskipoff(){
41        $in  = '@hey$you';
42        $out = '%40hey%24you';
43        $this->assertEquals(auth_nameencode($in),$out);
44    }
45
46    // include a two byte utf8 character which shouldn't be encoded
47    function test_hebrew(){
48        $in = 'nun-נ8';
49        $expect = 'nun%2dנ8';
50
51        $this->assertEquals($expect, auth_nameencode($in));
52    }
53
54    // include a three byte utf8 character which shouldn't be encoded
55    function test_devanagiri(){
56        $in = 'ut-fठ8';
57        $expect = 'ut%2dfठ8';
58
59        $this->assertEquals($expect, auth_nameencode($in));
60    }
61}
62
63//Setup VIM: ex: et ts=4 :
64