summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-06-08 12:36:08 -0700
committerAndreas Gohr <andi@splitbrain.org>2013-06-08 12:36:08 -0700
commita0376fb908efe76fcdeca5132e5aab8b0412c84a (patch)
tree14ec37075d19eea80399fe72181e9a02f8b35502 /_test
parent04e4890db370bdb57201f76581fe3dc0a3adb614 (diff)
parentdcb2204bf0a8e3e25bf4ff8352a71160e846266b (diff)
downloadrpg-a0376fb908efe76fcdeca5132e5aab8b0412c84a.tar.gz
rpg-a0376fb908efe76fcdeca5132e5aab8b0412c84a.tar.bz2
Merge pull request #223 from splitbrain/rootids_in_ml
Clean internal ids in ml(), that it matches with fetch.php
Diffstat (limited to '_test')
-rw-r--r--_test/tests/inc/common_ml.test.php52
-rw-r--r--_test/tests/inc/pageutils_clean_id.test.php4
2 files changed, 48 insertions, 8 deletions
diff --git a/_test/tests/inc/common_ml.test.php b/_test/tests/inc/common_ml.test.php
index 0abfde37a..9f3d87598 100644
--- a/_test/tests/inc/common_ml.test.php
+++ b/_test/tests/inc/common_ml.test.php
@@ -20,8 +20,8 @@ class common_ml_test extends DokuWikiTest {
$args = array('a' => 'b', 'c' => 'd', 'q' => '&ä');
- $expect = DOKU_BASE . $this->script . '?a=b&amp;c=d&amp;q=%26%C3%A4&amp;media=some:';
- $this->assertEquals($expect, ml('some:', $args));
+ $expect = DOKU_BASE . $this->script . '?a=b&amp;c=d&amp;q=%26%C3%A4&amp;media=some:img.jpg';
+ $this->assertEquals($expect, ml('some:img.jpg', $args));
}
function test_ml_args_string() {
@@ -31,8 +31,8 @@ class common_ml_test extends DokuWikiTest {
$args = 'a=b&c=d';
- $expect = DOKU_BASE . $this->script . '?a=b&c=d&amp;media=some:';
- $this->assertEquals($expect, ml('some:', $args));
+ $expect = DOKU_BASE . $this->script . '?a=b&c=d&amp;media=some:img.png';
+ $this->assertEquals($expect, ml('some:img.png', $args));
}
function test_ml_args_comma_string() {
@@ -42,8 +42,8 @@ class common_ml_test extends DokuWikiTest {
$args = 'a=b,c=d';
- $expect = DOKU_BASE . $this->script . '?a=b&amp;c=d&amp;media=some:';
- $this->assertEquals($expect, ml('some:', $args));
+ $expect = DOKU_BASE . $this->script . '?a=b&amp;c=d&amp;media=some:img.gif';
+ $this->assertEquals($expect, ml('some:img.gif', $args));
}
@@ -52,7 +52,7 @@ class common_ml_test extends DokuWikiTest {
$conf['useslash'] = 0;
$conf['userewrite'] = 0;
- $id = 'some:';
+ $id = 'some:img.png';
$w = 80;
$args = array('w' => $w);
$tok = media_get_token($id,$w,0);
@@ -66,7 +66,7 @@ class common_ml_test extends DokuWikiTest {
$conf['useslash'] = 0;
$conf['userewrite'] = 0;
- $id = 'some:';
+ $id = 'some:img.png';
$w = 80;
$args = 'w='.$w;
$tok = media_get_token($id,$w,0);
@@ -74,4 +74,40 @@ class common_ml_test extends DokuWikiTest {
$expect = DOKU_BASE . $this->script . '?w='.$w.'&amp;tok='.$tok.'&amp;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.'&amp;tok='.$tok.'&amp;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);
+
+ $expect = DOKU_BASE.$this->script.'?hash='.substr(md5(auth_cookiesalt().$id), 0, 6).'&amp;w='.$w.'&amp;tok='.$tok.'&amp;media='.rawurlencode($id);
+ $this->assertEquals($expect, ml($id, $args));
+ }
+ }
}
diff --git a/_test/tests/inc/pageutils_clean_id.test.php b/_test/tests/inc/pageutils_clean_id.test.php
index 9c5781b24..478fd2bc4 100644
--- a/_test/tests/inc/pageutils_clean_id.test.php
+++ b/_test/tests/inc/pageutils_clean_id.test.php
@@ -43,6 +43,10 @@ class init_clean_id_test extends DokuWikiTest {
$tests[] = array('ns._#!ns:page','false','ns._ns:page');
$tests[] = array('ns_:page',false,'ns:page');
$tests[] = array('page...page','false','page...page');
+ $tests[] = array(':page',false,'page');
+ $tests[] = array(':ns:page',false,'ns:page');
+ $tests[] = array('page:',false,'page');
+ $tests[] = array('ns:page:',false,'ns:page');
$conf['useslash'] = 0;
$tests[] = array('page/page',false,'page_page');