Skip to content
Snippets Groups Projects
Commit 1d7c1f1b authored by Yurii K's avatar Yurii K
Browse files

response on review

parent e8da0265
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,15 @@
*/
class TestUtils {
/**
* converts path to unix-like on windows OS
* @param string $path UNIX-like path to be converted
* @return string
*/
public static function w2u($path) {
return isWindows() ? str_replace('\\', '/', $path) : $path;
}
/**
* helper for recursive copy()
*
......
......@@ -73,6 +73,10 @@ class mailer_test extends DokuWikiTest {
}
function test_addresses(){
if (isWindows()) {
$this->markTestSkipped();
}
$mail = new TestMailer();
$mail->to('andi@splitbrain.org');
......@@ -88,49 +92,27 @@ class mailer_test extends DokuWikiTest {
$mail->to('Andreas Gohr <andi@splitbrain.org>');
$mail->cleanHeaders();
$headers = $mail->prop('headers');
if (isWindows()) { // see FS#652
$this->assertEquals('andi@splitbrain.org', $headers['To']);
} else {
$this->assertEquals('Andreas Gohr <andi@splitbrain.org>', $headers['To']);
}
$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');
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']);
}
$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');
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']);
}
$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');
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']);
}
$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');
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']);
}
$this->assertEquals('=?UTF-8?B?QmVldCwgTCB2YW4=?= <lvb@example.com>, foo <foo@example.com>', $headers['To']);
}
......
......@@ -4,13 +4,13 @@ class wikifn_test extends DokuWikiTest {
function test_cache_cleaning_cleanToUnclean(){
$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'));
$this->assertEquals(wikiFN('wiki:',null,false), TestUtils::w2u(DOKU_TMP_DATA.'pages/wiki/.txt'));
$this->assertEquals(wikiFN('wiki:',null,true), TestUtils::w2u(DOKU_TMP_DATA.'pages/wiki.txt'));
}
function test_cache_cleaning_uncleanToClean(){
$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'));
$this->assertEquals(wikiFN('wiki:',null,true), TestUtils::w2u(DOKU_TMP_DATA.'pages/wiki.txt'));
$this->assertEquals(wikiFN('wiki:',null,false), TestUtils::w2u(DOKU_TMP_DATA.'pages/wiki/.txt'));
}
}
......
......@@ -3,18 +3,12 @@
* Initialize some defaults needed for DokuWiki
*/
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;
}
/**
* checks it is windows OS
* @return bool
*/
function isWindows() {
return (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment