Added a test for AntTools::repairURL
This commit is contained in:
parent
588811ec7a
commit
4386451516
3 changed files with 33 additions and 2 deletions
|
@ -2,7 +2,7 @@ siteInfo:
|
|||
siteTitle: 'AntCMS'
|
||||
forceHTTPS: true
|
||||
activeTheme: Default
|
||||
generateKeywords: true
|
||||
generateKeywords: false
|
||||
enableCache: true
|
||||
admin:
|
||||
username: Admin
|
||||
|
|
|
@ -19,6 +19,11 @@ class MarkdownTest extends TestCase
|
|||
{
|
||||
$markdown = file_get_contents(antContentPath . DIRECTORY_SEPARATOR . 'index.md');
|
||||
$totalTime = 0;
|
||||
$currentConfig = AntConfig::currentConfig();
|
||||
|
||||
//Ensure cache is enabled
|
||||
$currentConfig['enableCache'] = true;
|
||||
AntConfig::saveConfig($currentConfig);
|
||||
|
||||
for ($i = 0; $i < 10; ++$i) {
|
||||
$start = microtime(true);
|
||||
|
|
|
@ -30,6 +30,32 @@ class ToolsTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
public function testUrlRepair()
|
||||
{
|
||||
$badUrls = array(
|
||||
"example.com\path",
|
||||
"example.com/path/",
|
||||
"example.com//path",
|
||||
"example.com/path/to//file",
|
||||
"example.com\path\\to\\file",
|
||||
"example.com\path\\to\\file?download=yes"
|
||||
);
|
||||
$expectedUrls = array(
|
||||
"example.com/path",
|
||||
"example.com/path/",
|
||||
"example.com/path",
|
||||
"example.com/path/to/file",
|
||||
"example.com/path/to/file",
|
||||
"example.com/path/to/file?download=yes"
|
||||
);
|
||||
|
||||
|
||||
foreach ($badUrls as $index => $badurl) {
|
||||
$goodUrl = AntTools::repairURL($badurl);
|
||||
$this->assertEquals($expectedUrls[$index], $goodUrl, "Expected '$expectedUrls[$index]' but got '{$goodUrl}' for input '{$badurl}'");
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetFileList()
|
||||
{
|
||||
$basedir = dirname(__DIR__, 1);
|
||||
|
|
Loading…
Reference in a new issue