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
|
<?php
class common_ml_test extends DokuWikiTest {
private $script = 'lib/exe/fetch.php';
function test_ml_empty() {
global $conf;
$conf['useslash'] = 0;
$conf['userewrite'] = 0;
$conf['start'] = 'start';
$this->assertEquals(DOKU_BASE . $this->script . '?media=' , ml());
}
function test_ml_args_array() {
global $conf;
$conf['useslash'] = 0;
$conf['userewrite'] = 0;
$args = array('a' => 'b', 'c' => 'd', 'q' => '&ä');
$expect = DOKU_BASE . $this->script . '?a=b&c=d&q=%26%C3%A4&media=some:img.jpg';
$this->assertEquals($expect, ml('some:img.jpg', $args));
}
function test_ml_args_string() {
global $conf;
$conf['useslash'] = 0;
$conf['userewrite'] = 0;
$args = 'a=b&c=d';
$expect = DOKU_BASE . $this->script . '?a=b&c=d&media=some:img.png';
$this->assertEquals($expect, ml('some:img.png', $args));
}
function test_ml_args_comma_string() {
global $conf;
$conf['useslash'] = 0;
$conf['userewrite'] = 0;
$args = 'a=b,c=d';
$expect = DOKU_BASE . $this->script . '?a=b&c=d&media=some:img.gif';
$this->assertEquals($expect, ml('some:img.gif', $args));
}
function test_ml_imgresize_array() {
global $conf;
$conf['useslash'] = 0;
$conf['userewrite'] = 0;
$id = 'some:img.png';
$w = 80;
$args = array('w' => $w);
$tok = media_get_token($id,$w,0);
$expect = DOKU_BASE . $this->script . '?w='.$w.'&tok='.$tok.'&media='.$id;
$this->assertEquals($expect, ml($id, $args));
}
function test_ml_imgresize_string() {
global $conf;
$conf['useslash'] = 0;
$conf['userewrite'] = 0;
$id = 'some:img.png';
$w = 80;
$args = 'w='.$w;
$tok = media_get_token($id,$w,0);
$expect = DOKU_BASE . $this->script . '?w='.$w.'&tok='.$tok.'&media='.$id;
$this->assertEquals($expect, ml($id, $args));
}
function test_ml_imgresize_array_rootid() {
global $conf;
$conf['useslash'] = 0;
$conf['userewrite'] = 0;
$id = ':wiki:dokuwiki-128.png';
$cleanid = 'wiki:dokuwiki-128.png';
$w = 80;
$args = array('w' => $w);
$tok = media_get_token($cleanid, $w, 0);
$expect = DOKU_BASE.$this->script.'?w='.$w.'&tok='.$tok.'&media='.$cleanid;
$this->assertEquals($expect, ml($id, $args));
}
function test_ml_imgresize_array_external() {
global $conf;
$conf['useslash'] = 0;
$conf['userewrite'] = 0;
$ids = array(
'https://example.com/lib/tpl/dokuwiki/images/logo.png',
'http://example.com/lib/tpl/dokuwiki/images/logo.png',
'ftp://example.com/lib/tpl/dokuwiki/images/logo.png'
);
$w = 80;
$args = array('w' => $w);
foreach($ids as $id) {
$tok = media_get_token($id, $w, 0);
$hash = substr(PassHash::hmac('md5', $id, auth_cookiesalt()), 0, 6);
$expect = DOKU_BASE.$this->script.'?hash='.$hash.'&w='.$w.'&tok='.$tok.'&media='.rawurlencode($id);
$this->assertEquals($expect, ml($id, $args));
}
}
}
|