diff options
Diffstat (limited to '_test/tests/inc')
-rw-r--r-- | _test/tests/inc/mailer.test.php | 46 | ||||
-rw-r--r-- | _test/tests/inc/tar.test.php | 23 |
2 files changed, 68 insertions, 1 deletions
diff --git a/_test/tests/inc/mailer.test.php b/_test/tests/inc/mailer.test.php index 053e216b8..ef78692b3 100644 --- a/_test/tests/inc/mailer.test.php +++ b/_test/tests/inc/mailer.test.php @@ -15,6 +15,11 @@ class TestMailer extends Mailer { public function prepareHeaders() { return parent::prepareHeaders(); } + + public function cleanHeaders() { + parent::cleanHeaders(); + } + } class mailer_test extends DokuWikiTest { @@ -67,6 +72,47 @@ class mailer_test extends DokuWikiTest { $this->assertArrayNotHasKey('Test-Header',$headers); } + function test_addresses(){ + $mail = new TestMailer(); + + $mail->to('andi@splitbrain.org'); + $mail->cleanHeaders(); + $headers = $mail->prop('headers'); + $this->assertEquals('andi@splitbrain.org', $headers['To']); + + $mail->to('<andi@splitbrain.org>'); + $mail->cleanHeaders(); + $headers = $mail->prop('headers'); + $this->assertEquals('andi@splitbrain.org', $headers['To']); + + $mail->to('Andreas Gohr <andi@splitbrain.org>'); + $mail->cleanHeaders(); + $headers = $mail->prop('headers'); + $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']); + + $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']); + + $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']); + + $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']); + + + } + function test_simplemail(){ global $conf; $conf['htmlmail'] = 0; diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index 9801ca1e0..417f1a853 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -58,6 +58,8 @@ class Tar_TestCase extends DokuWikiTest { $tar->addData('another/testdata3.txt', 'testcontent3'); $tar->close(); +copy ($tmp, '/tmp/test.tar'); + $this->assertTrue(filesize($tmp) > 30); //arbitrary non-zero number $data = file_get_contents($tmp); @@ -66,7 +68,7 @@ class Tar_TestCase extends DokuWikiTest { $this->assertTrue(strpos($data, 'testcontent3') !== false, 'Content in TAR'); // fullpath might be too long to be stored as full path FS#2802 - $this->assertTrue(strpos($data, "$tdir") !== false, 'Path in TAR'); + $this->assertTrue(strpos($data, "$tdir") !== false, "Path in TAR '$tdir'"); $this->assertTrue(strpos($data, "testdata1.txt") !== false, 'File in TAR'); $this->assertTrue(strpos($data, 'noway/testdata2.txt') !== false, 'Path in TAR'); @@ -396,4 +398,23 @@ class Tar_TestCase extends DokuWikiTest { $this->assertEquals(512*4, strlen($file)); // 1 header block + data block + 2 footer blocks } + + + public function test_cleanPath(){ + $tar = new Tar(); + $tests = array ( + '/foo/bar' => 'foo/bar', + '/foo/bar/' => 'foo/bar', + 'foo//bar' => 'foo/bar', + 'foo/0/bar' => 'foo/0/bar', + 'foo/../bar' => 'bar', + 'foo/bang/bang/../../bar' => 'foo/bar', + 'foo/../../bar' => 'bar', + 'foo/.././../bar' => 'bar', + ); + + foreach($tests as $in => $out){ + $this->assertEquals($out, $tar->cleanPath($in), "Input: $in"); + } + } } |