Permalink
Browse files

Fixed Bug #10792 No unit tests for recently fixed bugs

git-svn-id: http://svn.php.net/repository/pear/packages/Mail_Mime/trunk@234252 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent b5af758 commit ce5336fb97cd230142ff65408f20c0eeb5a0c548 @Cieper Cieper committed Apr 21, 2007
@@ -0,0 +1,18 @@
+--TEST--
+Bug #10298 Mail_mime, double Quotes and Specialchars in from and to Adress
+ Bug #10306 Strings with Double Quotes get encoded wrongly.
+--SKIPIF--
+--FILE--
+<?php
+error_reporting(E_ALL); // ignore E_STRICT
+include("Mail/mime.php");
+$mime = new Mail_mime();
+
+
+$string = '"German Umlauts öäü" <adresse@adresse.de>';
+
+$hdrs = $mime->_encodeHeaders(array('To'=>$string));
+
+print($hdrs['To']);
+--EXPECT--
+=?ISO-8859-1?Q?"German=20Umlauts=20=F6=E4=FC"=20<adresse@adresse.de>?=
@@ -0,0 +1,18 @@
+--TEST--
+Bug #10596 Incorrect handling of text and html '0' bodies
+--SKIPIF--
+--FILE--
+<?php
+error_reporting(E_ALL); // ignore E_STRICT
+include("Mail/mime.php");
+$mime = new Mail_mime();
+$mime->setTxtBody('0');
+$mime->setHTMLBody('0');
+$body = $mime->get();
+if ($body){
+ print("OK");
+}else{
+ print("NO BODY FOUND");
+}
+--EXPECT--
+OK
View
@@ -0,0 +1,34 @@
+--TEST--
+Bug #30 Mail_Mime: _encodeHeaders is not RFC-2047 compliant. (ISO-8859-1)
+--SKIPIF--
+--FILE--
+<?php
+error_reporting(E_ALL); // ignore E_STRICT
+include("Mail/mime.php");
+include("Mail/mimeDecode.php");
+$encoder = new Mail_mime();
+$decoder = new Mail_mimeDecode("");
+
+$input[] = "Just a simple test";
+$input[] = "_this=?Q?U:I:T:E_a_test?=";
+$input[] = "_=?Süper?=_";
+$input[] = "_ = ? Süper ? = _";
+$input[] = "Süper gröse tolle grüße?! Fur mir!?";
+$input[] = "Süper = gröse tolle grüße von mir";
+$input[] = "TEST Süper gröse tolle grüße von mir Süper gröse tolle grüße von mir Süper gröse tolle grüße von mir!!!?";
+$input[] = '"German Umlauts öäü"';
+
+$encoded = $encoder->_encodeHeaders($input, array('head_encoding' => 'quoted-printable'));
+$decoded = array();
+
+foreach ($encoded as $encodedString){
+ $decoded[] = $decoder->_decodeHeader($encodedString);
+}
+if ($input === $decoded){
+ print("MATCH");
+}else{
+ print("FAIL");
+}
+?>
+--EXPECT--
+MATCH
View
@@ -0,0 +1,36 @@
+--TEST--
+Bug #30 Mail_Mime: _encodeHeaders is not RFC-2047 compliant. (UTF-8)
+--SKIPIF--
+--FILE--
+<?php
+error_reporting(E_ALL); // ignore E_STRICT
+include("Mail/mime.php");
+include("Mail/mimeDecode.php");
+$encoder = new Mail_mime();
+$decoder = new Mail_mimeDecode("");
+
+$input[] = "Just a simple test";
+$input[] = "UTF-8 test for bug #30. #2 so Helgi Þormar Þorbjörnsson <dufuz@php.net> doesn't complain";
+$input[] = "Just a simple test";
+$input[] = "_this=?Q?U:I:T:E_a_test?=";
+$input[] = "_=?Süper?=_";
+$input[] = "_ = ? Süper ? = _";
+$input[] = "Süper gröse tolle grüße?! Fur mir!?";
+$input[] = "Süper = gröse tolle grüße von mir";
+$input[] = "TEST Süper gröse tolle grüße von mir Süper gröse tolle grüße von mir Süper gröse tolle grüße von mir!!!?";
+$input[] = '"German Umlauts öäü"';
+
+$encoded = $encoder->_encodeHeaders($input, array('head_encoding' => 'quoted-printable'));
+$decoded = array();
+
+foreach ($encoded as $encodedString){
+ $decoded[] = $decoder->_decodeHeader($encodedString);
+}
+if ($input === $decoded){
+ print("MATCH");
+}else{
+ print("FAIL");
+}
+?>
+--EXPECT--
+MATCH
View
@@ -0,0 +1,20 @@
+--TEST--
+Bug #3513 support of RFC2231 in header fields. (ISO-8859-1)
+--SKIPIF--
+--FILE--
+<?php
+error_reporting(E_ALL);
+$test = "Süper gröse tolle grüße.txt";
+require_once('Mail/mime.php');
+
+$Mime=new Mail_Mime();
+$Mime->setTXTBody('');
+$Mime->addAttachment('testfile',"text/plain", $test, FALSE, 'base64', 'attachment', 'iso-8859-1');
+
+$body = $Mime->get();
+$bodyarr=explode("\r\n",$body);
+print_r($bodyarr[3]."\r\n");
+print_r($bodyarr[4]."\r\n");
+?>
+--EXPECT--
+Content-Disposition: attachment; filename="=?iso-8859-1?Q?S=FCper?==?iso-8859-1?Q?_gr=F6se?= tolle=?iso-8859-1?Q?_gr=FC=DFe.txt?="
View
@@ -0,0 +1,20 @@
+--TEST--
+Bug #3513 support of RFC2231 in header fields. (UTF-8)
+--SKIPIF--
+--FILE--
+<?php
+error_reporting(E_ALL);
+$test = "Süper gröse tolle grüße.txt";
+require_once('Mail/mime.php');
+
+$Mime=new Mail_Mime();
+$Mime->setTXTBody('');
+$Mime->addAttachment('testfile',"text/plain", $test, FALSE, 'base64', 'attachment', 'UTF-8');
+
+$body = $Mime->get();
+$bodyarr=explode("\r\n",$body);
+print_r($bodyarr[3]."\r\n");
+print_r($bodyarr[4]."\r\n");
+?>
+--EXPECT--
+Content-Disposition: attachment; filename="=?UTF-8?Q?S=C3=BCper?==?UTF-8?Q?_gr=C3=B6se?= tolle=?UTF-8?Q?_gr=C3=BC=C3=9Fe.txt?="
View
@@ -0,0 +1,22 @@
+--TEST--
+Bug #3513 support of RFC2231 in header fields. (ISO-2022-JP)
+--SKIPIF--
+--FILE--
+<?php
+error_reporting(E_ALL);
+mb_internal_encoding('ISO-2022-JP');
+$testEncoded="GyRCRnxLXDhsGyhCLnR4dA==";
+$test = base64_decode($testEncoded); // Japanese filename in ISO-2022-JP charset.
+require_once('Mail/mime.php');
+
+$Mime=new Mail_Mime();
+$Mime->setTXTBody('');
+$Mime->addAttachment('testfile',"text/plain", $test, FALSE, 'base64', 'attachment', 'iso-2022-jp');
+
+$body = $Mime->get();
+$bodyarr=explode("\r\n",$body);
+print_r($bodyarr[3]."\r\n");
+print_r($bodyarr[4]."\r\n");
+?>
+--EXPECT--
+Content-Disposition: attachment; filename="=?iso-2022-jp?=1B=24BF=7CK=5C8l=1B=28B.txt?="
View
@@ -0,0 +1,30 @@
+--TEST--
+Bug #8223 Incorrectly encoded quoted-printable headers
+ Bug #10793 Long headers don't get wrapped since fix for Bug #10298
+--SKIPIF--
+--FILE--
+<?php
+error_reporting(E_ALL); // ignore E_STRICT
+include("Mail/mime.php");
+
+$encoder = new Mail_mime();
+$input[] = "A short test";
+$input[] = "A REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY /REALLY/ LONG test";
+$input[] = "TEST Süper gröse tolle grüße von mir Süper gröse tolle grüße von mir Süper gröse tolle grüße von mir Süper gröse tolle grüße von mir Süper gröse tolle grüße von mir Süper gröse tolle grüße von mir Süper gröse tolle grüße von mir Süper gröse tolle grüße von mir Süper gröse tolle grüße von mir!!!?";
+
+$encoded = $encoder->_encodeHeaders($input, array('head_encoding' => 'quoted-printable'));
+foreach ($encoded as $line){
+ if (strstr($line, '=?')){
+ $lines = explode("\n", $line);
+ foreach ($lines as $aLine){
+ if (strlen($aLine) > 75){
+ print("Line too long (" . strlen($aLine) . "):\n");
+ print($aLine);
+ print("\n");
+ }
+ }
+ }
+}
+print("OK");
+--EXPECT--
+OK
View
@@ -0,0 +1,22 @@
+--TEST--
+Bug #8386 HTML body not correctly encoded if attachments present
+--SKIPIF--
+--FILE--
+<?php
+error_reporting(E_ALL); // ignore E_STRICT
+define("MAIL_MIMEPART_CRLF", "#$#");
+include("Mail/mime.php");
+$encoder = new Mail_mime();
+$encoder->setTXTBody('test');
+$encoder->setHTMLBody('test');
+$encoder->addAttachment('Just a test', 'application/octet-stream', 'test.txt', false);
+$body = $encoder->get();
+if (strpos($body, '--' . MAIL_MIMEPART_CRLF . '--=')){
+ print("FAILED");
+ print("Single delimiter between 2 parts found.");
+}else{
+ print("OK");
+}
+?>
+--EXPECT--
+OK
View
@@ -0,0 +1,22 @@
+--TEST--
+Bug #9558 Broken multiline headers
+--SKIPIF--
+--FILE--
+<?php
+error_reporting(E_ALL); // ignore E_STRICT
+include("Mail/mime.php");
+
+$encoder = new Mail_mime();
+$input[] = "received by me
+ at some point
+ from some server";
+
+$encoded = $encoder->_encodeHeaders($input, array('head_encoding' => 'quoted-printable'));
+print_r($encoded);
+--EXPECT--
+Array
+(
+ [0] => received by me
+ at some point
+ from some server
+)
View
@@ -0,0 +1,26 @@
+--TEST--
+Bug #9722 _quotedPrintableEncode does not encode dot at start of line on Windows platform
+--SKIPIF--
+--FILE--
+<?php
+error_reporting(E_ALL); // ignore E_STRICT
+include("Mail/mimePart.php");
+define('MAIL_MIMEPART_CRLF', "\n");
+$text = "This
+is a
+test
+...
+ It is
+//really fun//
+to make :(";
+
+print_r(Mail_mimePart::_quotedPrintableEncode($text));
+
+--EXPECT--
+This
+is a
+test
+=2E..
+ It is=20
+//really fun//
+to make :(
View
@@ -0,0 +1,31 @@
+--TEST--
+Bug #9725 multipart/related & alternative wrong order
+--SKIPIF--
+--FILE--
+<?php
+error_reporting(E_ALL); // ignore E_STRICT
+include("Mail/mime.php");
+
+$mime = new Mail_mime();
+$mime->setTXTBody("test");
+$mime->setHTMLBody("test");
+$mime->addHTMLImage("test", 'application/octet-stream', '', false);
+$body = $mime->get();
+$head = $mime->headers();
+$headCT = $head['Content-Type'];
+$headCT = explode(";", $headCT);
+$headCT = $headCT[0];
+$ct = preg_match_all('|Content-Type: (.*);|', $body, $matches);
+print($headCT);
+print("\n");
+foreach ($matches[1] as $match){
+ print($match);
+ print("\n");
+}
+
+--EXPECT--
+multipart/related
+multipart/alternative
+text/plain
+text/html
+application/octet-stream
View
@@ -0,0 +1,19 @@
+--TEST--
+Bug #9976 Subject encoded twice
+--SKIPIF--
+--FILE--
+<?php
+error_reporting(E_ALL); // ignore E_STRICT
+include("Mail/mime.php");
+
+$mime = new Mail_mime();
+$body = $mime->get(array('text_charset'=>'UTF-8',
+ 'text_encoding'=>'8bit',
+ 'head_charset'=>'UTF-8'
+ )
+ );
+$hdrs = $mime->headers(array('Subject'=>'Nový Nový!'));
+
+print($hdrs['Subject']);
+--EXPECT--
+=?UTF-8?Q?Nov=C3=BD=20Nov=C3=BD!?=

0 comments on commit ce5336f

Please sign in to comment.