cleaning
This commit is contained in:
parent
30085ef376
commit
7b0d379feb
|
@ -3,11 +3,6 @@
|
|||
* Test Suite bootstrapping for DokuWiki
|
||||
*/
|
||||
|
||||
// convert windows path to unix-like
|
||||
function w2u($filename) {
|
||||
return str_replace('\\', '/', $filename);
|
||||
}
|
||||
|
||||
if(!defined('DOKU_UNITTEST')) define('DOKU_UNITTEST',dirname(__FILE__).'/');
|
||||
require_once DOKU_UNITTEST.'core/phpQuery-onefile.php';
|
||||
require_once DOKU_UNITTEST.'core/DokuWikiTest.php';
|
||||
|
@ -26,8 +21,8 @@ set_time_limit(0);
|
|||
ini_set('memory_limit','2048M');
|
||||
|
||||
// prepare temporary directories
|
||||
define('DOKU_INC', w2u(dirname(dirname(__FILE__))).'/');
|
||||
define('TMP_DIR', w2u(sys_get_temp_dir()).'/dwtests-'.microtime(true));
|
||||
define('DOKU_INC', dirname(dirname(__FILE__)).'/');
|
||||
define('TMP_DIR', sys_get_temp_dir().'/dwtests-'.microtime(true));
|
||||
define('DOKU_CONF', TMP_DIR.'/conf/');
|
||||
define('DOKU_TMP_DATA', TMP_DIR.'/data/');
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@ class wikifn_test extends DokuWikiTest {
|
|||
|
||||
|
||||
function test_cache_cleaning_cleanToUnclean(){
|
||||
$this->assertEquals(wikiFN('wiki:',null,false),DOKU_TMP_DATA.'pages/wiki/.txt');
|
||||
$this->assertEquals(wikiFN('wiki:',null,true),DOKU_TMP_DATA.'pages/wiki.txt');
|
||||
$this->assertEquals(wikiFN('wiki:',null,false), w2u(DOKU_TMP_DATA.'pages/wiki/.txt'));
|
||||
$this->assertEquals(wikiFN('wiki:',null,true), w2u(DOKU_TMP_DATA.'pages/wiki.txt'));
|
||||
}
|
||||
|
||||
function test_cache_cleaning_uncleanToClean(){
|
||||
$this->assertEquals(wikiFN('wiki:',null,true),DOKU_TMP_DATA.'pages/wiki.txt');
|
||||
$this->assertEquals(wikiFN('wiki:',null,false),DOKU_TMP_DATA.'pages/wiki/.txt');
|
||||
$this->assertEquals(wikiFN('wiki:',null,true), w2u(DOKU_TMP_DATA.'pages/wiki.txt'));
|
||||
$this->assertEquals(wikiFN('wiki:',null,false), w2u(DOKU_TMP_DATA.'pages/wiki/.txt'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class css_at_import_less_test extends DokuWikiTest {
|
|||
throw new Exception('failed to rename file');
|
||||
};
|
||||
|
||||
$this->import = w2u($import.'.less');
|
||||
$this->import = $import.'.less';
|
||||
}
|
||||
|
||||
private function csstest($input, $expected_css, $expected_less) {
|
||||
|
@ -34,14 +34,20 @@ class css_at_import_less_test extends DokuWikiTest {
|
|||
io_saveFile($this->file, $input);
|
||||
$css = css_loadfile($this->file, $location);
|
||||
$less = css_parseless($css);
|
||||
$this->assertEquals($expected_css, $css);
|
||||
$this->assertEquals($expected_css, w2u($css)); // w2u() for test pass, less works with both slashes on Windows OS
|
||||
$this->assertEquals($expected_less, $less);
|
||||
}
|
||||
|
||||
public function test_basic() {
|
||||
$this->setUpFiles();
|
||||
|
||||
$import = preg_replace('#(^.*[/])#','',$this->import);
|
||||
// remove path
|
||||
if (isWindows()) {
|
||||
$import = preg_replace('#(^.*[\\\\])#','',$this->import);
|
||||
} else {
|
||||
$import = preg_replace('#(^.*[/])#','',$this->import);
|
||||
}
|
||||
|
||||
$in_css = '@import "'.$import.'";';
|
||||
$in_less = '@foo: "bar";
|
||||
content: @foo;';
|
||||
|
@ -56,7 +62,13 @@ content: @foo;';
|
|||
public function test_subdirectory() {
|
||||
$this->setUpFiles('/foo/bar');
|
||||
|
||||
$import = preg_replace('#(^.*[/])#','',$this->import);
|
||||
// remove path
|
||||
if (isWindows()) {
|
||||
$import = preg_replace('#(^.*[\\\\])#','',$this->import);
|
||||
} else {
|
||||
$import = preg_replace('#(^.*[/])#','',$this->import);
|
||||
}
|
||||
|
||||
$in_css = '@import "'.$import.'";';
|
||||
$in_less = '@foo: "bar";
|
||||
content: @foo;';
|
||||
|
|
14
inc/init.php
14
inc/init.php
|
@ -3,8 +3,18 @@
|
|||
* Initialize some defaults needed for DokuWiki
|
||||
*/
|
||||
|
||||
function isWindows() {
|
||||
return (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false;
|
||||
if (!function_exists('isWindows')) {
|
||||
// checks if it is windows OS
|
||||
function isWindows() {
|
||||
return (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('w2u')) {
|
||||
// convert windows path to unix-like on windows OS
|
||||
function w2u($filename) {
|
||||
return isWindows() ? str_replace('\\', '/', $filename) : $filename;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -467,17 +467,15 @@ class DokuCssFile {
|
|||
|
||||
if (is_null($this->relative_path)) {
|
||||
$basedir = array(DOKU_INC);
|
||||
$filedir = dirname($this->filepath);
|
||||
|
||||
// during testing, files may be found relative to a second base dir, TMP_DIR
|
||||
if (defined('DOKU_UNITTEST')) {
|
||||
$basedir[] = w2u(realpath(TMP_DIR));
|
||||
$filedir = w2u($filedir);
|
||||
$basedir[] = realpath(TMP_DIR);
|
||||
}
|
||||
|
||||
$basedir = array_map('preg_quote_cb', $basedir);
|
||||
$regex = '/^('.join('|',$basedir).')/';
|
||||
$this->relative_path = preg_replace($regex, '', $filedir);
|
||||
$this->relative_path = preg_replace($regex, '', dirname($this->filepath));
|
||||
}
|
||||
|
||||
return $this->relative_path;
|
||||
|
|
Loading…
Reference in New Issue