MessageAcceptanceTest.php 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. require_once 'swift_required.php';
  3. require_once 'Swift/Mime/SimpleMessageAcceptanceTest.php';
  4. class Swift_MessageAcceptanceTest
  5. extends Swift_Mime_SimpleMessageAcceptanceTest
  6. {
  7. public function testAddPartWrapper()
  8. {
  9. $message = $this->_createMessage();
  10. $message->setSubject('just a test subject');
  11. $message->setFrom(array(
  12. 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn'));
  13. $id = $message->getId();
  14. $date = $message->getDate();
  15. $boundary = $message->getBoundary();
  16. $message->addPart('foo', 'text/plain', 'iso-8859-1');
  17. $message->addPart('test <b>foo</b>', 'text/html', 'iso-8859-1');
  18. $this->assertEqual(
  19. 'Message-ID: <' . $id . '>' . "\r\n" .
  20. 'Date: ' . date('r', $date) . "\r\n" .
  21. 'Subject: just a test subject' . "\r\n" .
  22. 'From: Chris Corbyn <chris.corbyn@swiftmailer.org>' . "\r\n" .
  23. 'MIME-Version: 1.0' . "\r\n" .
  24. 'Content-Type: multipart/alternative;' . "\r\n" .
  25. ' boundary="' . $boundary . '"' . "\r\n" .
  26. "\r\n\r\n" .
  27. '--' . $boundary . "\r\n" .
  28. 'Content-Type: text/plain; charset=iso-8859-1' . "\r\n" .
  29. 'Content-Transfer-Encoding: quoted-printable' . "\r\n" .
  30. "\r\n" .
  31. 'foo' .
  32. "\r\n\r\n" .
  33. '--' . $boundary . "\r\n" .
  34. 'Content-Type: text/html; charset=iso-8859-1' . "\r\n" .
  35. 'Content-Transfer-Encoding: quoted-printable' . "\r\n" .
  36. "\r\n" .
  37. 'test <b>foo</b>' .
  38. "\r\n\r\n" .
  39. '--' . $boundary . '--' . "\r\n",
  40. $message->toString()
  41. );
  42. }
  43. // -- Private helpers
  44. protected function _createMessage()
  45. {
  46. Swift_DependencyContainer::getInstance()
  47. ->register('properties.charset')->asValue(null);
  48. return Swift_Message::newInstance();
  49. }
  50. }