xref: /dokuwiki/_test/tests/inc/common_ml.test.php (revision a3d0aa224c509ed311955813d6eb459d1dc141c8)
1*a3d0aa22SChristopher Smith<?php
2*a3d0aa22SChristopher Smith
3*a3d0aa22SChristopher Smithclass common_wl_test extends DokuWikiTest {
4*a3d0aa22SChristopher Smith
5*a3d0aa22SChristopher Smith    private $script = 'lib/exe/fetch.php';
6*a3d0aa22SChristopher Smith
7*a3d0aa22SChristopher Smith    function test_ml_empty() {
8*a3d0aa22SChristopher Smith        global $conf;
9*a3d0aa22SChristopher Smith        $conf['useslash'] = 0;
10*a3d0aa22SChristopher Smith        $conf['userewrite'] = 0;
11*a3d0aa22SChristopher Smith        $conf['start'] = 'start';
12*a3d0aa22SChristopher Smith
13*a3d0aa22SChristopher Smith        $this->assertEquals(DOKU_BASE . $this->script . '?media=' , ml());
14*a3d0aa22SChristopher Smith    }
15*a3d0aa22SChristopher Smith
16*a3d0aa22SChristopher Smith    function test_ml_args_array() {
17*a3d0aa22SChristopher Smith        global $conf;
18*a3d0aa22SChristopher Smith        $conf['useslash'] = 0;
19*a3d0aa22SChristopher Smith        $conf['userewrite'] = 0;
20*a3d0aa22SChristopher Smith
21*a3d0aa22SChristopher Smith        $args = array('a' => 'b', 'c' => 'd', 'q' => '&ä');
22*a3d0aa22SChristopher Smith
23*a3d0aa22SChristopher Smith        $expect = DOKU_BASE . $this->script . '?a=b&amp;c=d&amp;q=%26%C3%A4&amp;media=some:';
24*a3d0aa22SChristopher Smith        $this->assertEquals($expect, ml('some:', $args));
25*a3d0aa22SChristopher Smith    }
26*a3d0aa22SChristopher Smith
27*a3d0aa22SChristopher Smith    function test_ml_args_string() {
28*a3d0aa22SChristopher Smith        global $conf;
29*a3d0aa22SChristopher Smith        $conf['useslash'] = 0;
30*a3d0aa22SChristopher Smith        $conf['userewrite'] = 0;
31*a3d0aa22SChristopher Smith
32*a3d0aa22SChristopher Smith        $args = 'a=b&c=d';
33*a3d0aa22SChristopher Smith
34*a3d0aa22SChristopher Smith        $expect = DOKU_BASE . $this->script . '?a=b&c=d&amp;media=some:';
35*a3d0aa22SChristopher Smith        $this->assertEquals($expect, ml('some:', $args));
36*a3d0aa22SChristopher Smith    }
37*a3d0aa22SChristopher Smith
38*a3d0aa22SChristopher Smith    function test_ml_args_comma_string() {
39*a3d0aa22SChristopher Smith        global $conf;
40*a3d0aa22SChristopher Smith        $conf['useslash'] = 0;
41*a3d0aa22SChristopher Smith        $conf['userewrite'] = 0;
42*a3d0aa22SChristopher Smith
43*a3d0aa22SChristopher Smith        $args = 'a=b,c=d';
44*a3d0aa22SChristopher Smith
45*a3d0aa22SChristopher Smith        $expect = DOKU_BASE . $this->script . '?a=b&amp;c=d&amp;media=some:';
46*a3d0aa22SChristopher Smith        $this->assertEquals($expect, ml('some:', $args));
47*a3d0aa22SChristopher Smith    }
48*a3d0aa22SChristopher Smith
49*a3d0aa22SChristopher Smith
50*a3d0aa22SChristopher Smith    function test_ml_imgresize_array() {
51*a3d0aa22SChristopher Smith        global $conf;
52*a3d0aa22SChristopher Smith        $conf['useslash'] = 0;
53*a3d0aa22SChristopher Smith        $conf['userewrite'] = 0;
54*a3d0aa22SChristopher Smith
55*a3d0aa22SChristopher Smith        $id = 'some:';
56*a3d0aa22SChristopher Smith        $w = 80;
57*a3d0aa22SChristopher Smith        $args = array('w' => $w);
58*a3d0aa22SChristopher Smith        $tok = media_get_token($id,$w,0);
59*a3d0aa22SChristopher Smith
60*a3d0aa22SChristopher Smith        $expect = DOKU_BASE . $this->script . '?w='.$w.'&amp;tok='.$tok.'&amp;media='.$id;
61*a3d0aa22SChristopher Smith        $this->assertEquals($expect, ml($id, $args));
62*a3d0aa22SChristopher Smith    }
63*a3d0aa22SChristopher Smith
64*a3d0aa22SChristopher Smith    function test_ml_imgresize_string() {
65*a3d0aa22SChristopher Smith        global $conf;
66*a3d0aa22SChristopher Smith        $conf['useslash'] = 0;
67*a3d0aa22SChristopher Smith        $conf['userewrite'] = 0;
68*a3d0aa22SChristopher Smith
69*a3d0aa22SChristopher Smith        $id = 'some:';
70*a3d0aa22SChristopher Smith        $w = 80;
71*a3d0aa22SChristopher Smith        $args = 'w='.$w;
72*a3d0aa22SChristopher Smith        $tok = media_get_token($id,$w,0);
73*a3d0aa22SChristopher Smith
74*a3d0aa22SChristopher Smith        $expect = DOKU_BASE . $this->script . '?w='.$w.'&amp;tok='.$tok.'&amp;media='.$id;
75*a3d0aa22SChristopher Smith        $this->assertEquals($expect, ml($id, $args));
76*a3d0aa22SChristopher Smith    }
77*a3d0aa22SChristopher Smith}