summaryrefslogtreecommitdiff
path: root/_test/tests/inc/common_wl.test.php
blob: 4bfde3f3945c9e75ec94abbba23b74b105f41bb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php

class common_wl_test extends DokuWikiTest {

    function test_wl_empty() {
        global $conf;
        $conf['useslash'] = 0;
        $conf['userewrite'] = 0;
        $conf['start'] = 'start';

        $this->assertEquals(DOKU_BASE . DOKU_SCRIPT . '?id=start' , wl());
    }

    function test_wl_empty_rewrite1() {
        global $conf;
        $conf['useslash'] = 0;
        $conf['userewrite'] = 1;
        $conf['start'] = 'start';

        $this->assertEquals(DOKU_BASE . 'start' , wl());
    }

    function test_wl_empty_rewrite2() {
        global $conf;
        $conf['useslash'] = 0;
        $conf['userewrite'] = 2;
        $conf['start'] = 'start';

        $this->assertEquals(DOKU_BASE . DOKU_SCRIPT . '/start' , wl());
    }

    function test_wl_id() {
        global $conf;
        $conf['useslash'] = 0;
        $conf['userewrite'] = 0;

        $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some';
        $this->assertEquals($expect, wl('some'));
    }

    function test_wl_id_ns() {
        global $conf;
        $conf['useslash'] = 0;
        $conf['userewrite'] = 0;

        $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:some';
        $this->assertEquals($expect, wl('some:some'));
    }

    function test_wl_id_ns_start() {
        global $conf;
        $conf['useslash'] = 0;
        $conf['userewrite'] = 0;

        $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:';
        $this->assertEquals($expect, wl('some:'));
    }

    function test_wl_args_array() {
        global $conf;
        $conf['useslash'] = 0;
        $conf['userewrite'] = 0;

        $args = array('a' => 'b', 'c' => 'd', 'q' => '&ä');

        $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&amp;a=b&amp;c=d&amp;q=%26%C3%A4';
        $this->assertEquals($expect, wl('some:', $args));
    }

    function test_wl_args_string() {
        global $conf;
        $conf['useslash'] = 0;
        $conf['userewrite'] = 0;

        $args = 'a=b&c=d';

        $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&amp;a=b&c=d';
        $this->assertEquals($expect, wl('some:', $args));
    }

    function test_wl_args_comma_string() {
        global $conf;
        $conf['useslash'] = 0;
        $conf['userewrite'] = 0;

        $args = 'a=b,c=d';

        $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&amp;a=b&amp;c=d';
        $this->assertEquals($expect, wl('some:', $args));
    }

    function test_wl_abs() {
        global $conf;
        $conf['useslash'] = 0;
        $conf['userewrite'] = 0;

        $expect = DOKU_URL . DOKU_SCRIPT . '?id=some:';
        $this->assertEquals($expect, wl('some:', '', true));
    }

    function test_wl_sep() {
        global $conf;
        $conf['useslash'] = 0;
        $conf['userewrite'] = 0;

        $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&a=b&c=d';
        $this->assertEquals($expect, wl('some:', 'a=b,c=d', false, '&'));
    }

    function test_wl_useslash() {
        global $conf;
        $conf['useslash'] = 1;
        $conf['userewrite'] = 0;

        $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&a=b&c=d';
        $this->assertEquals($expect, wl('some:', 'a=b,c=d', false, '&'));
    }

    function test_wl_useslash_rewrite1() {
        global $conf;
        $conf['useslash'] = 1;
        $conf['userewrite'] = 1;

        $expect = DOKU_BASE . 'some/?a=b&c=d';
        $this->assertEquals($expect, wl('some:', 'a=b,c=d', false, '&'));
    }

    function test_wl_useslash_rewrite1_sub_page() {
        global $conf;
        $conf['useslash'] = 1;
        $conf['userewrite'] = 1;

        $expect = DOKU_BASE . 'some/one?a=b&c=d';
        $this->assertEquals($expect, wl('some:one', 'a=b,c=d', false, '&'));
    }

    function test_wl_useslash_rewrite2() {
        global $conf;
        $conf['useslash'] = 1;
        $conf['userewrite'] = 2;

        $expect = DOKU_BASE . DOKU_SCRIPT . '/some/one?a=b&c=d';
        $this->assertEquals($expect, wl('some:one', 'a=b,c=d', false, '&'));
    }
    
    function test_wl_empty_rev() {
        global $conf;
        $conf['useslash'] = 0;
        $conf['userewrite'] = 0;

        $args = array('a' => 'b', 'c' => 'd', 'rev' => '');

        $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&amp;a=b&amp;c=d';
        $this->assertEquals($expect, wl('some:', $args));
    }



}