summaryrefslogtreecommitdiff
path: root/vendor/swiftmailer/swiftmailer/tests/bug/Swift
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2019-11-17 20:45:02 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2019-11-17 20:45:02 +0100
commit8df3db566a3a937b45ebf11adb90d265e6f5e2d4 (patch)
tree4d541098d751d5a9acf8c12f6fb9f308ace066ac /vendor/swiftmailer/swiftmailer/tests/bug/Swift
downloadflyspray-8df3db566a3a937b45ebf11adb90d265e6f5e2d4.tar.xz
initial checking of customized version 1.0rc9
Diffstat (limited to 'vendor/swiftmailer/swiftmailer/tests/bug/Swift')
-rw-r--r--vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug111Test.php42
-rw-r--r--vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug118Test.php20
-rw-r--r--vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug206Test.php38
-rw-r--r--vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug274Test.php21
-rw-r--r--vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug34Test.php75
-rw-r--r--vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug35Test.php73
-rw-r--r--vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug38Test.php192
-rw-r--r--vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug518Test.php38
-rw-r--r--vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug51Test.php110
-rw-r--r--vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug534Test.php38
-rw-r--r--vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug650Test.php36
-rw-r--r--vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug71Test.php20
-rw-r--r--vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug76Test.php71
-rw-r--r--vendor/swiftmailer/swiftmailer/tests/bug/Swift/BugFileByteStreamConsecutiveReadCallsTest.php19
14 files changed, 793 insertions, 0 deletions
diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug111Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug111Test.php
new file mode 100644
index 0000000..ba29ba8
--- /dev/null
+++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug111Test.php
@@ -0,0 +1,42 @@
+<?php
+
+class Swift_Bug111Test extends \PHPUnit_Framework_TestCase
+{
+ public function testUnstructuredHeaderSlashesShouldNotBeEscaped()
+ {
+ $complicated_header = array(
+ 'to' => array(
+ 'email1@example.com',
+ 'email2@example.com',
+ 'email3@example.com',
+ 'email4@example.com',
+ 'email5@example.com',
+ ),
+ 'sub' => array(
+ '-name-' => array(
+ 'email1',
+ '"email2"',
+ 'email3\\',
+ 'email4',
+ 'email5',
+ ),
+ '-url-' => array(
+ 'http://google.com',
+ 'http://yahoo.com',
+ 'http://hotmail.com',
+ 'http://aol.com',
+ 'http://facebook.com',
+ ),
+ ),
+ );
+ $json = json_encode($complicated_header);
+
+ $message = new Swift_Message();
+ $headers = $message->getHeaders();
+ $headers->addTextHeader('X-SMTPAPI', $json);
+ $header = $headers->get('X-SMTPAPI');
+
+ $this->assertEquals('Swift_Mime_Headers_UnstructuredHeader', get_class($header));
+ $this->assertEquals($json, $header->getFieldBody());
+ }
+}
diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug118Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug118Test.php
new file mode 100644
index 0000000..40b5a77
--- /dev/null
+++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug118Test.php
@@ -0,0 +1,20 @@
+<?php
+
+class Swift_Bug118Test extends \PHPUnit_Framework_TestCase
+{
+ private $_message;
+
+ protected function setUp()
+ {
+ $this->_message = new Swift_Message();
+ }
+
+ public function testCallingGenerateIdChangesTheMessageId()
+ {
+ $currentId = $this->_message->getId();
+ $this->_message->generateId();
+ $newId = $this->_message->getId();
+
+ $this->assertNotEquals($currentId, $newId);
+ }
+}
diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug206Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug206Test.php
new file mode 100644
index 0000000..7563f4d
--- /dev/null
+++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug206Test.php
@@ -0,0 +1,38 @@
+<?php
+
+class Swift_Bug206Test extends \PHPUnit_Framework_TestCase
+{
+ private $_factory;
+
+ protected function setUp()
+ {
+ $factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory();
+ $headerEncoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder(
+ new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8')
+ );
+ $paramEncoder = new Swift_Encoder_Rfc2231Encoder(
+ new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8')
+ );
+ $grammar = new Swift_Mime_Grammar();
+ $this->_factory = new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $grammar);
+ }
+
+ public function testMailboxHeaderEncoding()
+ {
+ $this->_testHeaderIsFullyEncoded('email@example.org', 'Family Name, Name', ' "Family Name, Name" <email@example.org>');
+ $this->_testHeaderIsFullyEncoded('email@example.org', 'Family Namé, Name', ' Family =?utf-8?Q?Nam=C3=A9=2C?= Name');
+ $this->_testHeaderIsFullyEncoded('email@example.org', 'Family Namé , Name', ' Family =?utf-8?Q?Nam=C3=A9_=2C?= Name');
+ $this->_testHeaderIsFullyEncoded('email@example.org', 'Family Namé ;Name', ' Family =?utf-8?Q?Nam=C3=A9_=3BName?= ');
+ }
+
+ private function _testHeaderIsFullyEncoded($email, $name, $expected)
+ {
+ $mailboxHeader = $this->_factory->createMailboxHeader('To', array(
+ $email => $name,
+ ));
+
+ $headerBody = substr($mailboxHeader->toString(), 3, strlen($expected));
+
+ $this->assertEquals($expected, $headerBody);
+ }
+}
diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug274Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug274Test.php
new file mode 100644
index 0000000..f5f057a
--- /dev/null
+++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug274Test.php
@@ -0,0 +1,21 @@
+<?php
+
+class Swift_Bug274Test extends \PHPUnit_Framework_TestCase
+{
+ public function testEmptyFileNameAsAttachment()
+ {
+ $message = new Swift_Message();
+ $this->setExpectedException('Swift_IoException', 'The path cannot be empty');
+ $message->attach(Swift_Attachment::fromPath(''));
+ }
+
+ public function testNonEmptyFileNameAsAttachment()
+ {
+ $message = new Swift_Message();
+ try {
+ $message->attach(Swift_Attachment::fromPath(__FILE__));
+ } catch (Exception $e) {
+ $this->fail('Path should not be empty');
+ }
+ }
+}
diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug34Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug34Test.php
new file mode 100644
index 0000000..768bf3d
--- /dev/null
+++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug34Test.php
@@ -0,0 +1,75 @@
+<?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>'."\r\n".
+ 'Message-ID: <'.$id.'>'."\r\n".
+ 'Date: '.$date."\r\n".
+ 'Subject: test subject'."\r\n".
+ 'From: Other <other@domain.tld>'."\r\n".
+ 'To: User <user@domain.tld>'."\r\n".
+ 'MIME-Version: 1.0'."\r\n".
+ 'Content-Type: multipart/alternative;'."\r\n".
+ ' boundary="'.$boundary.'"'."\r\n".
+ "\r\n\r\n".
+ '--'.$boundary."\r\n".
+ 'Content-Type: text/plain; charset=utf-8'."\r\n".
+ 'Content-Transfer-Encoding: quoted-printable'."\r\n".
+ "\r\n".
+ 'plain part'.
+ "\r\n\r\n".
+ '--'.$boundary."\r\n".
+ 'Content-Type: multipart/related;'."\r\n".
+ ' boundary="(.*?)"'."\r\n".
+ "\r\n\r\n".
+ '--\\1'."\r\n".
+ 'Content-Type: text/html; charset=utf-8'."\r\n".
+ 'Content-Transfer-Encoding: quoted-printable'."\r\n".
+ "\r\n".
+ '<img.*?/>'.
+ "\r\n\r\n".
+ '--\\1'."\r\n".
+ 'Content-Type: image/gif; name=image.gif'."\r\n".
+ 'Content-Transfer-Encoding: base64'."\r\n".
+ 'Content-ID: <'.$cidVal.'>'."\r\n".
+ 'Content-Disposition: inline; filename=image.gif'."\r\n".
+ "\r\n".
+ preg_quote(base64_encode('<image data>'), '~').
+ "\r\n\r\n".
+ '--\\1--'."\r\n".
+ "\r\n\r\n".
+ '--'.$boundary.'--'."\r\n".
+ '$~D',
+ $message->toString()
+ );
+ }
+}
diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug35Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug35Test.php
new file mode 100644
index 0000000..98999f0
--- /dev/null
+++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug35Test.php
@@ -0,0 +1,73 @@
+<?php
+
+class Swift_Bug35Test extends \PHPUnit_Framework_TestCase
+{
+ protected function setUp()
+ {
+ Swift_Preferences::getInstance()->setCharset('utf-8');
+ }
+
+ public function testHTMLPartAppearsLastEvenWhenAttachmentsAdded()
+ {
+ $message = Swift_Message::newInstance();
+ $message->setCharset('utf-8');
+ $message->setSubject('test subject');
+ $message->addPart('plain part', 'text/plain');
+
+ $attachment = Swift_Attachment::newInstance('<data>', 'image.gif', 'image/gif');
+ $message->attach($attachment);
+
+ $message->setBody('HTML part', '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();
+
+ $this->assertRegExp(
+ '~^'.
+ 'Sender: Other <other@domain.tld>'."\r\n".
+ 'Message-ID: <'.$id.'>'."\r\n".
+ 'Date: '.$date."\r\n".
+ 'Subject: test subject'."\r\n".
+ 'From: Other <other@domain.tld>'."\r\n".
+ 'To: User <user@domain.tld>'."\r\n".
+ 'MIME-Version: 1.0'."\r\n".
+ 'Content-Type: multipart/mixed;'."\r\n".
+ ' boundary="'.$boundary.'"'."\r\n".
+ "\r\n\r\n".
+ '--'.$boundary."\r\n".
+ 'Content-Type: multipart/alternative;'."\r\n".
+ ' boundary="(.*?)"'."\r\n".
+ "\r\n\r\n".
+ '--\\1'."\r\n".
+ 'Content-Type: text/plain; charset=utf-8'."\r\n".
+ 'Content-Transfer-Encoding: quoted-printable'."\r\n".
+ "\r\n".
+ 'plain part'.
+ "\r\n\r\n".
+ '--\\1'."\r\n".
+ 'Content-Type: text/html; charset=utf-8'."\r\n".
+ 'Content-Transfer-Encoding: quoted-printable'."\r\n".
+ "\r\n".
+ 'HTML part'.
+ "\r\n\r\n".
+ '--\\1--'."\r\n".
+ "\r\n\r\n".
+ '--'.$boundary."\r\n".
+ 'Content-Type: image/gif; name=image.gif'."\r\n".
+ 'Content-Transfer-Encoding: base64'."\r\n".
+ 'Content-Disposition: attachment; filename=image.gif'."\r\n".
+ "\r\n".
+ preg_quote(base64_encode('<data>'), '~').
+ "\r\n\r\n".
+ '--'.$boundary.'--'."\r\n".
+ '$~D',
+ $message->toString()
+ );
+ }
+}
diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug38Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug38Test.php
new file mode 100644
index 0000000..9deae4f
--- /dev/null
+++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug38Test.php
@@ -0,0 +1,192 @@
+<?php
+
+class Swift_Bug38Test extends \PHPUnit_Framework_TestCase
+{
+ private $_attFile;
+ private $_attFileName;
+ private $_attFileType;
+
+ protected function setUp()
+ {
+ $this->_attFileName = 'data.txt';
+ $this->_attFileType = 'text/plain';
+ $this->_attFile = __DIR__.'/../../_samples/files/data.txt';
+ Swift_Preferences::getInstance()->setCharset('utf-8');
+ }
+
+ public function testWritingMessageToByteStreamProducesCorrectStructure()
+ {
+ $message = new Swift_Message();
+ $message->setSubject('test subject');
+ $message->setTo('user@domain.tld');
+ $message->setCc('other@domain.tld');
+ $message->setFrom('user@domain.tld');
+
+ $image = new Swift_Image('<data>', 'image.gif', 'image/gif');
+
+ $cid = $message->embed($image);
+ $message->setBody('HTML part', 'text/html');
+
+ $id = $message->getId();
+ $date = preg_quote(date('r', $message->getDate()), '~');
+ $boundary = $message->getBoundary();
+ $imgId = $image->getId();
+
+ $stream = new Swift_ByteStream_ArrayByteStream();
+
+ $message->toByteStream($stream);
+
+ $this->assertPatternInStream(
+ '~^'.
+ 'Message-ID: <'.$id.'>'."\r\n".
+ 'Date: '.$date."\r\n".
+ 'Subject: test subject'."\r\n".
+ 'From: user@domain.tld'."\r\n".
+ 'To: user@domain.tld'."\r\n".
+ 'Cc: other@domain.tld'."\r\n".
+ 'MIME-Version: 1.0'."\r\n".
+ 'Content-Type: multipart/related;'."\r\n".
+ ' boundary="'.$boundary.'"'."\r\n".
+ "\r\n\r\n".
+ '--'.$boundary."\r\n".
+ 'Content-Type: text/html; charset=utf-8'."\r\n".
+ 'Content-Transfer-Encoding: quoted-printable'."\r\n".
+ "\r\n".
+ 'HTML part'.
+ "\r\n\r\n".
+ '--'.$boundary."\r\n".
+ 'Content-Type: image/gif; name=image.gif'."\r\n".
+ 'Content-Transfer-Encoding: base64'."\r\n".
+ 'Content-ID: <'.preg_quote($imgId, '~').'>'."\r\n".
+ 'Content-Disposition: inline; filename=image.gif'."\r\n".
+ "\r\n".
+ preg_quote(base64_encode('<data>'), '~').
+ "\r\n\r\n".
+ '--'.$boundary.'--'."\r\n".
+ '$~D',
+ $stream
+ );
+ }
+
+ public function testWritingMessageToByteStreamTwiceProducesCorrectStructure()
+ {
+ $message = new Swift_Message();
+ $message->setSubject('test subject');
+ $message->setTo('user@domain.tld');
+ $message->setCc('other@domain.tld');
+ $message->setFrom('user@domain.tld');
+
+ $image = new Swift_Image('<data>', 'image.gif', 'image/gif');
+
+ $cid = $message->embed($image);
+ $message->setBody('HTML part', 'text/html');
+
+ $id = $message->getId();
+ $date = preg_quote(date('r', $message->getDate()), '~');
+ $boundary = $message->getBoundary();
+ $imgId = $image->getId();
+
+ $pattern = '~^'.
+ 'Message-ID: <'.$id.'>'."\r\n".
+ 'Date: '.$date."\r\n".
+ 'Subject: test subject'."\r\n".
+ 'From: user@domain.tld'."\r\n".
+ 'To: user@domain.tld'."\r\n".
+ 'Cc: other@domain.tld'."\r\n".
+ 'MIME-Version: 1.0'."\r\n".
+ 'Content-Type: multipart/related;'."\r\n".
+ ' boundary="'.$boundary.'"'."\r\n".
+ "\r\n\r\n".
+ '--'.$boundary."\r\n".
+ 'Content-Type: text/html; charset=utf-8'."\r\n".
+ 'Content-Transfer-Encoding: quoted-printable'."\r\n".
+ "\r\n".
+ 'HTML part'.
+ "\r\n\r\n".
+ '--'.$boundary."\r\n".
+ 'Content-Type: image/gif; name=image.gif'."\r\n".
+ 'Content-Transfer-Encoding: base64'."\r\n".
+ 'Content-ID: <'.preg_quote($imgId, '~').'>'."\r\n".
+ 'Content-Disposition: inline; filename=image.gif'."\r\n".
+ "\r\n".
+ preg_quote(base64_encode('<data>'), '~').
+ "\r\n\r\n".
+ '--'.$boundary.'--'."\r\n".
+ '$~D'
+ ;
+
+ $streamA = new Swift_ByteStream_ArrayByteStream();
+ $streamB = new Swift_ByteStream_ArrayByteStream();
+
+ $message->toByteStream($streamA);
+ $message->toByteStream($streamB);
+
+ $this->assertPatternInStream($pattern, $streamA);
+ $this->assertPatternInStream($pattern, $streamB);
+ }
+
+ public function testWritingMessageToByteStreamTwiceUsingAFileAttachment()
+ {
+ $message = new Swift_Message();
+ $message->setSubject('test subject');
+ $message->setTo('user@domain.tld');
+ $message->setCc('other@domain.tld');
+ $message->setFrom('user@domain.tld');
+
+ $attachment = Swift_Attachment::fromPath($this->_attFile);
+
+ $message->attach($attachment);
+
+ $message->setBody('HTML part', 'text/html');
+
+ $id = $message->getId();
+ $date = preg_quote(date('r', $message->getDate()), '~');
+ $boundary = $message->getBoundary();
+
+ $streamA = new Swift_ByteStream_ArrayByteStream();
+ $streamB = new Swift_ByteStream_ArrayByteStream();
+
+ $pattern = '~^'.
+ 'Message-ID: <'.$id.'>'."\r\n".
+ 'Date: '.$date."\r\n".
+ 'Subject: test subject'."\r\n".
+ 'From: user@domain.tld'."\r\n".
+ 'To: user@domain.tld'."\r\n".
+ 'Cc: other@domain.tld'."\r\n".
+ 'MIME-Version: 1.0'."\r\n".
+ 'Content-Type: multipart/mixed;'."\r\n".
+ ' boundary="'.$boundary.'"'."\r\n".
+ "\r\n\r\n".
+ '--'.$boundary."\r\n".
+ 'Content-Type: text/html; charset=utf-8'."\r\n".
+ 'Content-Transfer-Encoding: quoted-printable'."\r\n".
+ "\r\n".
+ 'HTML part'.
+ "\r\n\r\n".
+ '--'.$boundary."\r\n".
+ 'Content-Type: '.$this->_attFileType.'; name='.$this->_attFileName."\r\n".
+ 'Content-Transfer-Encoding: base64'."\r\n".
+ 'Content-Disposition: attachment; filename='.$this->_attFileName."\r\n".
+ "\r\n".
+ preg_quote(base64_encode(file_get_contents($this->_attFile)), '~').
+ "\r\n\r\n".
+ '--'.$boundary.'--'."\r\n".
+ '$~D'
+ ;
+
+ $message->toByteStream($streamA);
+ $message->toByteStream($streamB);
+
+ $this->assertPatternInStream($pattern, $streamA);
+ $this->assertPatternInStream($pattern, $streamB);
+ }
+
+ public function assertPatternInStream($pattern, $stream, $message = '%s')
+ {
+ $string = '';
+ while (false !== $bytes = $stream->read(8192)) {
+ $string .= $bytes;
+ }
+ $this->assertRegExp($pattern, $string, $message);
+ }
+}
diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug518Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug518Test.php
new file mode 100644
index 0000000..b83984f
--- /dev/null
+++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug518Test.php
@@ -0,0 +1,38 @@
+<?php
+
+use Mockery as m;
+
+class Swift_Bug518Test extends \PHPUnit_Framework_TestCase
+{
+ public function testIfEmailChangesAfterQueued()
+ {
+ $failedRecipients = 'value';
+ $message = new Swift_Message();
+ $message->setTo('foo@bar.com');
+
+ $that = $this;
+ $messageValidation = function ($m) use ($that) {
+ //the getTo should return the same value as we put in
+ $that->assertEquals('foo@bar.com', key($m->getTo()), 'The message has changed after it was put to the memory queue');
+
+ return true;
+ };
+
+ $transport = m::mock('Swift_Transport');
+ $transport->shouldReceive('isStarted')->andReturn(true);
+ $transport->shouldReceive('send')
+ ->with(m::on($messageValidation), $failedRecipients)
+ ->andReturn(1);
+
+ $memorySpool = new Swift_MemorySpool();
+ $memorySpool->queueMessage($message);
+
+ /*
+ * The message is queued in memory.
+ * Lets change the message
+ */
+ $message->setTo('other@value.com');
+
+ $memorySpool->flushQueue($transport, $failedRecipients);
+ }
+}
diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug51Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug51Test.php
new file mode 100644
index 0000000..48074f0
--- /dev/null
+++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug51Test.php
@@ -0,0 +1,110 @@
+<?php
+
+class Swift_Bug51Test extends \SwiftMailerTestCase
+{
+ private $_attachmentFile;
+ private $_outputFile;
+
+ protected function setUp()
+ {
+ $this->_attachmentFile = sys_get_temp_dir().'/attach.rand.bin';
+ file_put_contents($this->_attachmentFile, '');
+
+ $this->_outputFile = sys_get_temp_dir().'/attach.out.bin';
+ file_put_contents($this->_outputFile, '');
+ }
+
+ protected function tearDown()
+ {
+ unlink($this->_attachmentFile);
+ unlink($this->_outputFile);
+ }
+
+ public function testAttachmentsDoNotGetTruncatedUsingToByteStream()
+ {
+ //Run 100 times with 10KB attachments
+ for ($i = 0; $i < 10; ++$i) {
+ $message = $this->_createMessageWithRandomAttachment(
+ 10000, $this->_attachmentFile
+ );
+
+ file_put_contents($this->_outputFile, '');
+ $message->toByteStream(
+ new Swift_ByteStream_FileByteStream($this->_outputFile, true)
+ );
+
+ $emailSource = file_get_contents($this->_outputFile);
+
+ $this->assertAttachmentFromSourceMatches(
+ file_get_contents($this->_attachmentFile),
+ $emailSource
+ );
+ }
+ }
+
+ public function testAttachmentsDoNotGetTruncatedUsingToString()
+ {
+ //Run 100 times with 10KB attachments
+ for ($i = 0; $i < 10; ++$i) {
+ $message = $this->_createMessageWithRandomAttachment(
+ 10000, $this->_attachmentFile
+ );
+
+ $emailSource = $message->toString();
+
+ $this->assertAttachmentFromSourceMatches(
+ file_get_contents($this->_attachmentFile),
+ $emailSource
+ );
+ }
+ }
+
+ public function assertAttachmentFromSourceMatches($attachmentData, $source)
+ {
+ $encHeader = 'Content-Transfer-Encoding: base64';
+ $base64declaration = strpos($source, $encHeader);
+
+ $attachmentDataStart = strpos($source, "\r\n\r\n", $base64declaration);
+ $attachmentDataEnd = strpos($source, "\r\n--", $attachmentDataStart);
+
+ if (false === $attachmentDataEnd) {
+ $attachmentBase64 = trim(substr($source, $attachmentDataStart));
+ } else {
+ $attachmentBase64 = trim(substr(
+ $source, $attachmentDataStart,
+ $attachmentDataEnd - $attachmentDataStart
+ ));
+ }
+
+ $this->assertIdenticalBinary($attachmentData, base64_decode($attachmentBase64));
+ }
+
+ private function _fillFileWithRandomBytes($byteCount, $file)
+ {
+ // I was going to use dd with if=/dev/random but this way seems more
+ // cross platform even if a hella expensive!!
+
+ file_put_contents($file, '');
+ $fp = fopen($file, 'wb');
+ for ($i = 0; $i < $byteCount; ++$i) {
+ $byteVal = rand(0, 255);
+ fwrite($fp, pack('i', $byteVal));
+ }
+ fclose($fp);
+ }
+
+ private function _createMessageWithRandomAttachment($size, $attachmentPath)
+ {
+ $this->_fillFileWithRandomBytes($size, $attachmentPath);
+
+ $message = Swift_Message::newInstance()
+ ->setSubject('test')
+ ->setBody('test')
+ ->setFrom('a@b.c')
+ ->setTo('d@e.f')
+ ->attach(Swift_Attachment::fromPath($attachmentPath))
+ ;
+
+ return $message;
+ }
+}
diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug534Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug534Test.php
new file mode 100644
index 0000000..263cae5
--- /dev/null
+++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug534Test.php
@@ -0,0 +1,38 @@
+<?php
+
+use Mockery as m;
+
+class Swift_Bug534Test extends \PHPUnit_Framework_TestCase
+{
+ public function testEmbeddedImagesAreEmbedded()
+ {
+ $message = Swift_Message::newInstance()
+ ->setFrom('from@example.com')
+ ->setTo('to@example.com')
+ ->setSubject('test')
+ ;
+ $cid = $message->embed(Swift_Image::fromPath(__DIR__.'/../../_samples/files/swiftmailer.png'));
+ $message->setBody('<img src="'.$cid.'" />', 'text/html');
+
+ $that = $this;
+ $messageValidation = function (Swift_Mime_Message $message) use ($that) {
+ preg_match('/cid:(.*)"/', $message->toString(), $matches);
+ $cid = $matches[1];
+ preg_match('/Content-ID: <(.*)>/', $message->toString(), $matches);
+ $contentId = $matches[1];
+ $that->assertEquals($cid, $contentId, 'cid in body and mime part Content-ID differ');
+
+ return true;
+ };
+
+ $failedRecipients = array();
+
+ $transport = m::mock('Swift_Transport');
+ $transport->shouldReceive('isStarted')->andReturn(true);
+ $transport->shouldReceive('send')->with(m::on($messageValidation), $failedRecipients)->andReturn(1);
+
+ $memorySpool = new Swift_MemorySpool();
+ $memorySpool->queueMessage($message);
+ $memorySpool->flushQueue($transport, $failedRecipients);
+ }
+}
diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug650Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug650Test.php
new file mode 100644
index 0000000..3393fb8
--- /dev/null
+++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug650Test.php
@@ -0,0 +1,36 @@
+<?php
+
+class Swift_Bug650Test extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @dataProvider encodingDataProvider
+ *
+ * @param string $name
+ * @param string $expectedEncodedName
+ */
+ public function testMailboxHeaderEncoding($name, $expectedEncodedName)
+ {
+ $factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory();
+ $charStream = new Swift_CharacterStream_NgCharacterStream($factory, 'utf-8');
+ $encoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder($charStream);
+ $header = new Swift_Mime_Headers_MailboxHeader('To', $encoder, new Swift_Mime_Grammar());
+ $header->setCharset('utf-8');
+
+ $header->setNameAddresses(array(
+ 'test@example.com' => $name,
+ ));
+
+ $this->assertSame('To: '.$expectedEncodedName." <test@example.com>\r\n", $header->toString());
+ }
+
+ public function encodingDataProvider()
+ {
+ return array(
+ array('this is " a test ö', 'this is =?utf-8?Q?=22?= a test =?utf-8?Q?=C3=B6?='),
+ array(': this is a test ö', '=?utf-8?Q?=3A?= this is a test =?utf-8?Q?=C3=B6?='),
+ array('( test ö', '=?utf-8?Q?=28?= test =?utf-8?Q?=C3=B6?='),
+ array('[ test ö', '=?utf-8?Q?=5B?= test =?utf-8?Q?=C3=B6?='),
+ array('@ test ö)', '=?utf-8?Q?=40?= test =?utf-8?Q?=C3=B6=29?='),
+ );
+ }
+}
diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug71Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug71Test.php
new file mode 100644
index 0000000..d58242f
--- /dev/null
+++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug71Test.php
@@ -0,0 +1,20 @@
+<?php
+
+class Swift_Bug71Test extends \PHPUnit_Framework_TestCase
+{
+ private $_message;
+
+ protected function setUp()
+ {
+ $this->_message = new Swift_Message('test');
+ }
+
+ public function testCallingToStringAfterSettingNewBodyReflectsChanges()
+ {
+ $this->_message->setBody('BODY1');
+ $this->assertRegExp('/BODY1/', $this->_message->toString());
+
+ $this->_message->setBody('BODY2');
+ $this->assertRegExp('/BODY2/', $this->_message->toString());
+ }
+}
diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug76Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug76Test.php
new file mode 100644
index 0000000..899083c
--- /dev/null
+++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug76Test.php
@@ -0,0 +1,71 @@
+<?php
+
+class Swift_Bug76Test extends \PHPUnit_Framework_TestCase
+{
+ private $_inputFile;
+ private $_outputFile;
+ private $_encoder;
+
+ protected function setUp()
+ {
+ $this->_inputFile = sys_get_temp_dir().'/in.bin';
+ file_put_contents($this->_inputFile, '');
+
+ $this->_outputFile = sys_get_temp_dir().'/out.bin';
+ file_put_contents($this->_outputFile, '');
+
+ $this->_encoder = $this->_createEncoder();
+ }
+
+ protected function tearDown()
+ {
+ unlink($this->_inputFile);
+ unlink($this->_outputFile);
+ }
+
+ public function testBase64EncodedLineLengthNeverExceeds76CharactersEvenIfArgsDo()
+ {
+ $this->_fillFileWithRandomBytes(1000, $this->_inputFile);
+
+ $os = $this->_createStream($this->_inputFile);
+ $is = $this->_createStream($this->_outputFile);
+
+ $this->_encoder->encodeByteStream($os, $is, 0, 80); //Exceeds 76
+
+ $this->assertMaxLineLength(76, $this->_outputFile,
+ '%s: Line length should not exceed 76 characters'
+ );
+ }
+
+ public function assertMaxLineLength($length, $filePath, $message = '%s')
+ {
+ $lines = file($filePath);
+ foreach ($lines as $line) {
+ $this->assertTrue((strlen(trim($line)) <= 76), $message);
+ }
+ }
+
+ private function _fillFileWithRandomBytes($byteCount, $file)
+ {
+ // I was going to use dd with if=/dev/random but this way seems more
+ // cross platform even if a hella expensive!!
+
+ file_put_contents($file, '');
+ $fp = fopen($file, 'wb');
+ for ($i = 0; $i < $byteCount; ++$i) {
+ $byteVal = rand(0, 255);
+ fwrite($fp, pack('i', $byteVal));
+ }
+ fclose($fp);
+ }
+
+ private function _createEncoder()
+ {
+ return new Swift_Mime_ContentEncoder_Base64ContentEncoder();
+ }
+
+ private function _createStream($file)
+ {
+ return new Swift_ByteStream_FileByteStream($file, true);
+ }
+}
diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/BugFileByteStreamConsecutiveReadCallsTest.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/BugFileByteStreamConsecutiveReadCallsTest.php
new file mode 100644
index 0000000..35733ec
--- /dev/null
+++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/BugFileByteStreamConsecutiveReadCallsTest.php
@@ -0,0 +1,19 @@
+<?php
+
+
+class Swift_FileByteStreamConsecutiveReadCalls extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @test
+ * @expectedException \Swift_IoException
+ */
+ public function shouldThrowExceptionOnConsecutiveRead()
+ {
+ $fbs = new \Swift_ByteStream_FileByteStream('does not exist');
+ try {
+ $fbs->read(100);
+ } catch (\Swift_IoException $exc) {
+ $fbs->read(100);
+ }
+ }
+}