diff options
author | Gerrit Uitslag <klapinklapin@gmail.com> | 2014-03-16 21:52:10 +0100 |
---|---|---|
committer | Gerrit Uitslag <klapinklapin@gmail.com> | 2014-03-16 21:52:10 +0100 |
commit | 02fdb912950b25bafecfc3f3f4d2b4be5352453b (patch) | |
tree | f1c67d720c96065ec343492dd6b301ba0060869a /_test/tests/inc/parser/renderer_resolveinterwiki.test.php | |
parent | e9ac0877f6c7eb3536f8f2b6b2a431c00de8fe4f (diff) | |
parent | 4d5fc927eace8f4208895cd309d23fc9025dbb6b (diff) | |
download | rpg-02fdb912950b25bafecfc3f3f4d2b4be5352453b.tar.gz rpg-02fdb912950b25bafecfc3f3f4d2b4be5352453b.tar.bz2 |
Merge pull request #527 from splitbrain/userlink
Linked and formatted user names
Diffstat (limited to '_test/tests/inc/parser/renderer_resolveinterwiki.test.php')
-rw-r--r-- | _test/tests/inc/parser/renderer_resolveinterwiki.test.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php new file mode 100644 index 000000000..7b43b6d62 --- /dev/null +++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php @@ -0,0 +1,53 @@ +<?php + +require_once DOKU_INC . 'inc/parser/renderer.php'; + +/** + * Tests for Doku_Renderer::_resolveInterWiki() + */ +class Test_resolveInterwiki extends PHPUnit_Framework_TestCase { + + function testDefaults() { + $Renderer = new Doku_Renderer(); + $Renderer->interwiki = getInterwiki(); + $Renderer->interwiki['scheme'] = '{SCHEME}://example.com'; + $Renderer->interwiki['withslash'] = '/test'; + $Renderer->interwiki['onlytext'] = ':onlytext{NAME}'; //with {URL} double urlencoded + $Renderer->interwiki['withquery'] = ':anyns:{NAME}?do=edit'; + + $tests = array( + // shortcut, reference and expected + array('wp', 'foo @+%/#txt', 'http://en.wikipedia.org/wiki/foo @+%/#txt'), + array('amazon', 'foo @+%/#txt', 'http://www.amazon.com/exec/obidos/ASIN/foo%20%40%2B%25%2F/splitbrain-20/#txt'), + array('doku', 'foo @+%/#txt', 'http://www.dokuwiki.org/foo%20%40%2B%25%2F#txt'), + array('coral', 'http://example.com:83/path/naar/?query=foo%20%40%2B%25%2F', 'http://example.com.83.nyud.net:8090/path/naar/?query=foo%20%40%2B%25%2F'), + array('scheme', 'ftp://foo @+%/#txt', 'ftp://example.com#txt'), + //relative url + array('withslash', 'foo @+%/#txt', '/testfoo%20%40%2B%25%2F#txt'), + array('skype', 'foo @+%/#txt', 'skype:foo @+%/#txt'), + //dokuwiki id's + array('onlytext', 'foo @+%#txt', DOKU_BASE.'doku.php?id=onlytextfoo#txt'), + array('user', 'foo @+%#txt', DOKU_BASE.'doku.php?id=user:foo#txt'), + array('withquery', 'foo @+%#txt', DOKU_BASE.'doku.php?id=anyns:foo&do=edit#txt') + ); + + foreach($tests as $test) { + $url = $Renderer->_resolveInterWiki($test[0], $test[1]); + + $this->assertEquals($test[2], $url); + } + } + + function testNonexisting() { + $Renderer = new Doku_Renderer(); + $Renderer->interwiki = getInterwiki(); + + $shortcut = 'nonexisting'; + $reference = 'foo @+%/'; + $url = $Renderer->_resolveInterWiki($shortcut, $reference); + $expected = 'http://www.google.com/search?q=foo%20%40%2B%25%2F&btnI=lucky'; + + $this->assertEquals($expected, $url); + } + +}
\ No newline at end of file |