xref: /dokuwiki/_test/tests/inc/common_wl.test.php (revision 9cf8b6e0e4b94473739d2b36a906a848b9410f7f)
1<?php
2
3class common_wl_test extends DokuWikiTest {
4
5    function test_wl_empty() {
6        global $conf;
7        $conf['useslash'] = 0;
8        $conf['userewrite'] = 0;
9        $conf['start'] = 'start';
10
11        $this->assertEquals(DOKU_BASE . DOKU_SCRIPT . '?id=start' , wl());
12    }
13
14    function test_wl_empty_rewrite1() {
15        global $conf;
16        $conf['useslash'] = 0;
17        $conf['userewrite'] = 1;
18        $conf['start'] = 'start';
19
20        $this->assertEquals(DOKU_BASE . 'start' , wl());
21    }
22
23    function test_wl_empty_rewrite2() {
24        global $conf;
25        $conf['useslash'] = 0;
26        $conf['userewrite'] = 2;
27        $conf['start'] = 'start';
28
29        $this->assertEquals(DOKU_BASE . DOKU_SCRIPT . '/start' , wl());
30    }
31
32    function test_wl_id() {
33        global $conf;
34        $conf['useslash'] = 0;
35        $conf['userewrite'] = 0;
36
37        $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some';
38        $this->assertEquals($expect, wl('some'));
39    }
40
41    function test_wl_id_ns() {
42        global $conf;
43        $conf['useslash'] = 0;
44        $conf['userewrite'] = 0;
45
46        $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:some';
47        $this->assertEquals($expect, wl('some:some'));
48    }
49
50    function test_wl_id_ns_start() {
51        global $conf;
52        $conf['useslash'] = 0;
53        $conf['userewrite'] = 0;
54
55        $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:';
56        $this->assertEquals($expect, wl('some:'));
57    }
58
59    function test_wl_args_array() {
60        global $conf;
61        $conf['useslash'] = 0;
62        $conf['userewrite'] = 0;
63
64        $args = array('a' => 'b', 'c' => 'd', 'q' => '&ä');
65
66        $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&amp;a=b&amp;c=d&amp;q=%26%C3%A4';
67        $this->assertEquals($expect, wl('some:', $args));
68    }
69
70    function test_wl_args_string() {
71        global $conf;
72        $conf['useslash'] = 0;
73        $conf['userewrite'] = 0;
74
75        $args = 'a=b&c=d';
76
77        $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&amp;a=b&c=d';
78        $this->assertEquals($expect, wl('some:', $args));
79    }
80
81    function test_wl_args_comma_string() {
82        global $conf;
83        $conf['useslash'] = 0;
84        $conf['userewrite'] = 0;
85
86        $args = 'a=b,c=d';
87
88        $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&amp;a=b&amp;c=d';
89        $this->assertEquals($expect, wl('some:', $args));
90    }
91
92    function test_wl_abs() {
93        global $conf;
94        $conf['useslash'] = 0;
95        $conf['userewrite'] = 0;
96
97        $expect = DOKU_URL . DOKU_SCRIPT . '?id=some:';
98        $this->assertEquals($expect, wl('some:', '', true));
99    }
100
101    function test_wl_sep() {
102        global $conf;
103        $conf['useslash'] = 0;
104        $conf['userewrite'] = 0;
105
106        $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&a=b&c=d';
107        $this->assertEquals($expect, wl('some:', 'a=b,c=d', false, '&'));
108    }
109
110    function test_wl_useslash() {
111        global $conf;
112        $conf['useslash'] = 1;
113        $conf['userewrite'] = 0;
114
115        $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&a=b&c=d';
116        $this->assertEquals($expect, wl('some:', 'a=b,c=d', false, '&'));
117    }
118
119    function test_wl_useslash_rewrite1() {
120        global $conf;
121        $conf['useslash'] = 1;
122        $conf['userewrite'] = 1;
123
124        $expect = DOKU_BASE . 'some/?a=b&c=d';
125        $this->assertEquals($expect, wl('some:', 'a=b,c=d', false, '&'));
126    }
127
128    function test_wl_useslash_rewrite1_sub_page() {
129        global $conf;
130        $conf['useslash'] = 1;
131        $conf['userewrite'] = 1;
132
133        $expect = DOKU_BASE . 'some/one?a=b&c=d';
134        $this->assertEquals($expect, wl('some:one', 'a=b,c=d', false, '&'));
135    }
136
137    function test_wl_useslash_rewrite2() {
138        global $conf;
139        $conf['useslash'] = 1;
140        $conf['userewrite'] = 2;
141
142        $expect = DOKU_BASE . DOKU_SCRIPT . '/some/one?a=b&c=d';
143        $this->assertEquals($expect, wl('some:one', 'a=b,c=d', false, '&'));
144    }
145
146
147
148}