xref: /dokuwiki/_test/tests/inc/auth_nameencode.test.php (revision 5a0eec47d375f076d810160503bdd303f8cf62a0)
1<?php
2
3require_once DOKU_INC.'inc/init.php';
4require_once DOKU_INC.'inc/auth.php';
5
6class auth_nameencode_test extends DokuWikiTest {
7
8    function teardown() {
9        global $cache_authname;
10        $cache_authname = array();
11    }
12
13    function test_simple(){
14        $in  = 'hey$you';
15        $out = 'hey%24you';
16        $this->assertEquals(auth_nameencode($in),$out);
17    }
18
19    function test_quote(){
20        $in  = 'hey"you';
21        $out = 'hey%22you';
22        $this->assertEquals(auth_nameencode($in),$out);
23    }
24
25    function test_complex(){
26        $in  = 'hey $ you !$%! foo ';
27        $out = 'hey%20%24%20you%20%21%24%25%21%20foo%20';
28        $this->assertEquals(auth_nameencode($in),$out);
29    }
30
31    function test_complexutf8(){
32        $in  = 'häü $ yü !$%! foo ';
33        $out = 'häü%20%24%20yü%20%21%24%25%21%20foo%20';
34        $this->assertEquals(auth_nameencode($in),$out);
35    }
36
37    function test_groupskipon(){
38        $in  = '@hey$you';
39        $out = '@hey%24you';
40        $this->assertEquals(auth_nameencode($in,true),$out);
41    }
42
43    function test_groupskipoff(){
44        $in  = '@hey$you';
45        $out = '%40hey%24you';
46        $this->assertEquals(auth_nameencode($in),$out);
47    }
48}
49
50//Setup VIM: ex: et ts=4 :
51