xref: /plugin/siteexport/_test/plugin_siteexport_functions_getrelativeurl.test.php (revision c572fbc5b393ffdaf18871c3fd7d96b54e2ed811)
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 test_functionsExist() {
12        $this->assertTrue( class_exists('siteexport_functions'), 'The class for the functions could not be found.' );
13    }
14
15    /**
16     * @depends test_functionsExist
17     */
18    public function test_getRelativeURL() {
19
20        $functions = new siteexport_functions();
21        // $functions->debug->setDebugLevel(1);
22        // $functions->debug->setDebugFile('/tmp/siteexport.log');
23
24        $testMatrix = array(
25
26            // Same directory
27            array(
28                'base'      => "test/test.html",
29                'relative'  => "../test/test2.html",
30                'expected'  => "test2.html",
31            ),
32
33            // Same directory at base
34            array(
35                'base'      => "test.html",
36                'relative'  => "test2.html",
37                'expected'  => "test2.html",
38            ),
39
40            // Different directory
41            array(
42                'base'      => "test.html",
43                'relative'  => "../test/test2.html",
44                'expected'  => "test/test2.html",
45            ),
46
47            array(
48                'base'      => "test/test.html",
49                'relative'  => "../test2.html",
50                'expected'  => "../test2.html",
51            ),
52
53            array(
54                'base'      => "test/test.html",
55                'relative'  => "../test2/test2.html",
56                'expected'  => "../test2/test2.html",
57            ),
58        );
59
60        foreach($testMatrix as $test) {
61            $result = $functions->getRelativeURL($test['relative'], $test['base']);
62            $this->assertTrue($test['expected'] == $result, "Result '{$result}' did not match expected result '{$test['expected']}' (base: '{$test['base']}', relative: '{$test['relative']}')");
63        }
64   }
65
66}
67