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'
|
siteTitle: 'AntCMS'
|
||||||
forceHTTPS: true
|
forceHTTPS: true
|
||||||
activeTheme: Default
|
activeTheme: Default
|
||||||
generateKeywords: true
|
generateKeywords: false
|
||||||
enableCache: true
|
enableCache: true
|
||||||
admin:
|
admin:
|
||||||
username: Admin
|
username: Admin
|
||||||
|
|
|
@ -19,6 +19,11 @@ class MarkdownTest extends TestCase
|
||||||
{
|
{
|
||||||
$markdown = file_get_contents(antContentPath . DIRECTORY_SEPARATOR . 'index.md');
|
$markdown = file_get_contents(antContentPath . DIRECTORY_SEPARATOR . 'index.md');
|
||||||
$totalTime = 0;
|
$totalTime = 0;
|
||||||
|
$currentConfig = AntConfig::currentConfig();
|
||||||
|
|
||||||
|
//Ensure cache is enabled
|
||||||
|
$currentConfig['enableCache'] = true;
|
||||||
|
AntConfig::saveConfig($currentConfig);
|
||||||
|
|
||||||
for ($i = 0; $i < 10; ++$i) {
|
for ($i = 0; $i < 10; ++$i) {
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
|
@ -69,7 +74,7 @@ class MarkdownTest extends TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
$withCache = $totalTime / 10;
|
$withCache = $totalTime / 10;
|
||||||
|
|
||||||
echo "\n Markdown rendering speed with cache: {$withCache} VS without: {$withoutCache} \n\n";
|
echo "\n Markdown rendering speed with cache: {$withCache} VS without: {$withoutCache} \n\n";
|
||||||
$this->assertLessThan($withoutCache, $withCache, "Cache didn't speed up rendering!");
|
$this->assertLessThan($withoutCache, $withCache, "Cache didn't speed up rendering!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
public function testGetFileList()
|
||||||
{
|
{
|
||||||
$basedir = dirname(__DIR__, 1);
|
$basedir = dirname(__DIR__, 1);
|
||||||
|
|
Loading…
Reference in a new issue