xref: /plugin/siteexport/_test/plugin_siteexport_functions_getrelativeurl.test.php (revision 3aa0ad132b323f1afef9d443f43b22322b57a827)
1<?php
2
3/**
4 * @group plugin_siteexport
5 * @group plugins
6 */
7class SiteexportFunctionsGetRelativeURLTest extends DokuWikiTest {
8
9    protected $pluginsEnabled = array('siteexport');
10
11    public function testGetRelativeURL() {
12
13        $functions = new siteexport_functions();
14        $functions->debug->setDebugLevel(1);
15        $functions->debug->setDebugFile('/tmp/siteexport.log');
16
17        $testMatrix = array(
18
19            array(
20                'base'      => "test/test.html",
21                'relative'  => "../test/test2.html",
22                'expected'  => "test2.html",
23            ),
24
25            array(
26                'base'      => "test.html",
27                'relative'  => "test2.html",
28                'expected'  => "test2.html",
29            ),
30
31            array(
32                'base'      => "test.html",
33                'relative'  => "../test/test2.html",
34                'expected'  => "test/test2.html",
35            ),
36
37            array(
38                'base'      => "test/test.html",
39                'relative'  => "../test2.html",
40                'expected'  => "../test2.html",
41            ),
42
43            array(
44                'base'      => "test/test.html",
45                'relative'  => "../test2/test2.html",
46                'expected'  => "../test2/test2.html",
47            ),
48        );
49
50        foreach($testMatrix as $test) {
51            $result = $functions->getRelativeURL($test['relative'], $test['base']);
52            $this->assertTrue($test['expected'] == $result, "Result '{$result}' did not match expected result '{$test['expected']}' (base: '{$test['base']}', relative: '{$test['relative']}')");
53        }
54   }
55
56}
57