Файл: gapps/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug34Test.php
Строк: 120
<?php
class Swift_Bug34Test extends PHPUnit_Framework_TestCase
{
protected function setUp()
{
Swift_Preferences::getInstance()->setCharset('utf-8');
}
public function testEmbeddedFilesWithMultipartDataCreateMultipartRelatedContentAsAnAlternative()
{
$message = Swift_Message::newInstance();
$message->setCharset('utf-8');
$message->setSubject('test subject');
$message->addPart('plain part', 'text/plain');
$image = Swift_Image::newInstance('<image data>', 'image.gif', 'image/gif');
$cid = $message->embed($image);
$message->setBody('<img src="'.$cid.'" />', 'text/html');
$message->setTo(array('user@domain.tld' => 'User'));
$message->setFrom(array('other@domain.tld' => 'Other'));
$message->setSender(array('other@domain.tld' => 'Other'));
$id = $message->getId();
$date = preg_quote(date('r', $message->getDate()), '~');
$boundary = $message->getBoundary();
$cidVal = $image->getId();
$this->assertRegExp(
'~^'.
'Sender: Other <other@domain.tld>'."rn".
'Message-ID: <'.$id.'>'."rn".
'Date: '.$date."rn".
'Subject: test subject'."rn".
'From: Other <other@domain.tld>'."rn".
'To: User <user@domain.tld>'."rn".
'MIME-Version: 1.0'."rn".
'Content-Type: multipart/alternative;'."rn".
' boundary="'.$boundary.'"'."rn".
"rnrn".
'--'.$boundary."rn".
'Content-Type: text/plain; charset=utf-8'."rn".
'Content-Transfer-Encoding: quoted-printable'."rn".
"rn".
'plain part'.
"rnrn".
'--'.$boundary."rn".
'Content-Type: multipart/related;'."rn".
' boundary="(.*?)"'."rn".
"rnrn".
'--\1'."rn".
'Content-Type: text/html; charset=utf-8'."rn".
'Content-Transfer-Encoding: quoted-printable'."rn".
"rn".
'<img.*?/>'.
"rnrn".
'--\1'."rn".
'Content-Type: image/gif; name=image.gif'."rn".
'Content-Transfer-Encoding: base64'."rn".
'Content-ID: <'.$cidVal.'>'."rn".
'Content-Disposition: inline; filename=image.gif'."rn".
"rn".
preg_quote(base64_encode('<image data>'), '~').
"rnrn".
'--\1--'."rn".
"rnrn".
'--'.$boundary.'--'."rn".
'$~D',
$message->toString()
);
}
}