1<?php 2 3require_once(DOKU_PLUGIN . 'siteexport/inc/functions.php'); 4 5/** 6 * @group plugin_siteexport 7 * @group plugins 8 */ 9class SiteexportFunctionsGetRelativeURLTest extends DokuWikiTest { 10 11 protected $pluginsEnabled = array('siteexport'); 12 13 public function test_functionsExist() { 14 $this->assertFileExists(DOKU_PLUGIN . 'siteexport/inc/functions.php', 'The functions.php file could not be found.'); 15 $this->assertTrue(class_exists('siteexport_functions'), 'The class for the functions could not be found.'); 16 } 17 18 /** 19 * @depends test_functionsExist 20 */ 21 public function test_getRelativeURL() { 22 23 $functions = new siteexport_functions(); 24 // $functions->debug->setDebugLevel(1); 25 // $functions->debug->setDebugFile('/tmp/siteexport.log'); 26 27 $testMatrix = array( 28 29 // Same directory 30 array( 31 'base' => "test/test.html", 32 'relative' => "../test/test2.html", 33 'expected' => "test2.html", 34 ), 35 36 // Same directory at base 37 array( 38 'base' => "test.html", 39 'relative' => "test2.html", 40 'expected' => "test2.html", 41 ), 42 43 // Different directory 44 array( 45 'base' => "test.html", 46 'relative' => "../test/test2.html", 47 'expected' => "test/test2.html", 48 ), 49 50 array( 51 'base' => "test/test.html", 52 'relative' => "../test2.html", 53 'expected' => "../test2.html", 54 ), 55 56 array( 57 'base' => "test/test.html", 58 'relative' => "../test2/test2.html", 59 'expected' => "../test2/test2.html", 60 ), 61 ); 62 63 foreach ($testMatrix as $test) { 64 $result = $functions->getRelativeURL($test['relative'], $test['base']); 65 $this->assertTrue($test['expected'] == $result, "Result '{$result}' did not match expected result '{$test['expected']}' (base: '{$test['base']}', relative: '{$test['relative']}')"); 66 } 67 } 68 69} 70