fix tests on windows
This commit is contained in:
parent
7dbafed4f4
commit
30085ef376
|
@ -3,6 +3,11 @@
|
|||
* 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';
|
||||
|
@ -21,8 +26,8 @@ set_time_limit(0);
|
|||
ini_set('memory_limit','2048M');
|
||||
|
||||
// prepare temporary directories
|
||||
define('DOKU_INC', dirname(dirname(__FILE__)).'/');
|
||||
define('TMP_DIR', sys_get_temp_dir().'/dwtests-'.microtime(true));
|
||||
define('DOKU_INC', w2u(dirname(dirname(__FILE__))).'/');
|
||||
define('TMP_DIR', w2u(sys_get_temp_dir()).'/dwtests-'.microtime(true));
|
||||
define('DOKU_CONF', TMP_DIR.'/conf/');
|
||||
define('DOKU_TMP_DATA', TMP_DIR.'/data/');
|
||||
|
||||
|
|
|
@ -88,27 +88,49 @@ class mailer_test extends DokuWikiTest {
|
|||
$mail->to('Andreas Gohr <andi@splitbrain.org>');
|
||||
$mail->cleanHeaders();
|
||||
$headers = $mail->prop('headers');
|
||||
$this->assertEquals('Andreas Gohr <andi@splitbrain.org>', $headers['To']);
|
||||
|
||||
if (isWindows()) { // see FS#652
|
||||
$this->assertEquals('andi@splitbrain.org', $headers['To']);
|
||||
} else {
|
||||
$this->assertEquals('Andreas Gohr <andi@splitbrain.org>', $headers['To']);
|
||||
}
|
||||
|
||||
$mail->to('Andreas Gohr <andi@splitbrain.org> , foo <foo@example.com>');
|
||||
$mail->cleanHeaders();
|
||||
$headers = $mail->prop('headers');
|
||||
$this->assertEquals('Andreas Gohr <andi@splitbrain.org>, foo <foo@example.com>', $headers['To']);
|
||||
if (isWindows()) { // see FS#652
|
||||
$this->assertEquals('andi@splitbrain.org, foo@example.com', $headers['To']);
|
||||
} else {
|
||||
$this->assertEquals('Andreas Gohr <andi@splitbrain.org>, foo <foo@example.com>', $headers['To']);
|
||||
}
|
||||
|
||||
$mail->to('Möp <moep@example.com> , foo <foo@example.com>');
|
||||
$mail->cleanHeaders();
|
||||
$headers = $mail->prop('headers');
|
||||
$this->assertEquals('=?UTF-8?B?TcO2cA==?= <moep@example.com>, foo <foo@example.com>', $headers['To']);
|
||||
|
||||
if (isWindows()) { // see FS#652
|
||||
$this->assertEquals('moep@example.com, foo@example.com', $headers['To']);
|
||||
} else {
|
||||
$this->assertEquals('=?UTF-8?B?TcO2cA==?= <moep@example.com>, foo <foo@example.com>', $headers['To']);
|
||||
}
|
||||
|
||||
$mail->to(array('Möp <moep@example.com> ',' foo <foo@example.com>'));
|
||||
$mail->cleanHeaders();
|
||||
$headers = $mail->prop('headers');
|
||||
$this->assertEquals('=?UTF-8?B?TcO2cA==?= <moep@example.com>, foo <foo@example.com>', $headers['To']);
|
||||
if (isWindows()) { // see FS#652
|
||||
$this->assertEquals('moep@example.com, foo@example.com', $headers['To']);
|
||||
} else {
|
||||
$this->assertEquals('=?UTF-8?B?TcO2cA==?= <moep@example.com>, foo <foo@example.com>', $headers['To']);
|
||||
}
|
||||
|
||||
$mail->to(array('Beet, L van <lvb@example.com>',' foo <foo@example.com>'));
|
||||
$mail->cleanHeaders();
|
||||
$headers = $mail->prop('headers');
|
||||
$this->assertEquals('=?UTF-8?B?QmVldCwgTCB2YW4=?= <lvb@example.com>, foo <foo@example.com>', $headers['To']);
|
||||
if (isWindows()) { // see FS#652
|
||||
$this->assertEquals('lvb@example.com, foo@example.com', $headers['To']);
|
||||
} else {
|
||||
$this->assertEquals('=?UTF-8?B?QmVldCwgTCB2YW4=?= <lvb@example.com>, foo <foo@example.com>', $headers['To']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -14,19 +14,19 @@ class css_at_import_less_test extends DokuWikiTest {
|
|||
mkdir($dir, 0777, true);
|
||||
}
|
||||
if (!is_dir($dir)) {
|
||||
$this->markTestSkipped('Could not create directory.');
|
||||
throw new Exception('Could not create directory.');
|
||||
}
|
||||
|
||||
$this->file = tempnam($dir, 'css');
|
||||
|
||||
$import = '';
|
||||
do {
|
||||
if ($import) unlink($import);
|
||||
$import = tempnam($dir, 'less');
|
||||
$ok = rename($import, $import.'.less');
|
||||
} while (!$ok);
|
||||
if ($import) unlink($import);
|
||||
$import = tempnam($dir, 'less');
|
||||
if (rename($import, $import.'.less') === false) {
|
||||
throw new Exception('failed to rename file');
|
||||
};
|
||||
|
||||
$this->import = $import.'.less';
|
||||
$this->import = w2u($import.'.less');
|
||||
}
|
||||
|
||||
private function csstest($input, $expected_css, $expected_less) {
|
||||
|
|
|
@ -331,9 +331,6 @@ class Mailer {
|
|||
* @return false|string the prepared header (can contain multiple lines)
|
||||
*/
|
||||
public function cleanAddress($addresses) {
|
||||
// No named recipients for To: in Windows (see FS#652)
|
||||
$names = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? false : true;
|
||||
|
||||
$headers = '';
|
||||
if(!is_array($addresses)){
|
||||
$addresses = explode(',', $addresses);
|
||||
|
@ -367,7 +364,7 @@ class Mailer {
|
|||
}
|
||||
|
||||
// text was given
|
||||
if(!empty($text) && $names) {
|
||||
if(!empty($text) && !isWindows()) { // No named recipients for To: in Windows (see FS#652)
|
||||
// add address quotes
|
||||
$addr = "<$addr>";
|
||||
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
* Initialize some defaults needed for DokuWiki
|
||||
*/
|
||||
|
||||
function isWindows() {
|
||||
return (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* timing Dokuwiki execution
|
||||
*
|
||||
|
|
|
@ -467,15 +467,17 @@ 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[] = realpath(TMP_DIR);
|
||||
$basedir[] = w2u(realpath(TMP_DIR));
|
||||
$filedir = w2u($filedir);
|
||||
}
|
||||
|
||||
$basedir = array_map('preg_quote_cb', $basedir);
|
||||
$regex = '/^('.join('|',$basedir).')/';
|
||||
$this->relative_path = preg_replace($regex, '', dirname($this->filepath));
|
||||
$this->relative_path = preg_replace($regex, '', $filedir);
|
||||
}
|
||||
|
||||
return $this->relative_path;
|
||||
|
|
Loading…
Reference in New Issue