HtmlWithAttachmentSmokeTest.php 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. require_once 'Swift/Tests/SwiftSmokeTestCase.php';
  3. class Swift_Smoke_HtmlWithAttachmentSmokeTest
  4. extends Swift_Tests_SwiftSmokeTestCase
  5. {
  6. public function setUp()
  7. {
  8. $this->_attFile = dirname(__FILE__) . '/../../../_samples/files/textfile.zip';
  9. }
  10. public function testAttachmentSending()
  11. {
  12. $mailer = $this->_getMailer();
  13. $message = Swift_Message::newInstance('[Swift Mailer] HtmlWithAttachmentSmokeTest')
  14. ->setFrom(array(SWIFT_SMOKE_EMAIL_ADDRESS => 'Swift Mailer'))
  15. ->setTo(SWIFT_SMOKE_EMAIL_ADDRESS)
  16. ->attach(Swift_Attachment::fromPath($this->_attFile))
  17. ->setBody('<p>This HTML-formatted message should contain an attached ZIP file (named "textfile.zip").' . PHP_EOL .
  18. 'When unzipped, the archive should produce a text file which reads:</p>' . PHP_EOL .
  19. '<p><q>This is part of a Swift Mailer v4 smoke test.</q></p>', 'text/html'
  20. )
  21. ;
  22. $this->assertEqual(1, $mailer->send($message),
  23. '%s: The smoke test should send a single message'
  24. );
  25. $this->_visualCheck('http://swiftmailer.org/smoke/4.0.0/attachment.jpg');
  26. }
  27. }