AttachmentSmokeTest.php 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. require_once 'Swift/Tests/SwiftSmokeTestCase.php';
  3. class Swift_Smoke_AttachmentSmokeTest extends Swift_Tests_SwiftSmokeTestCase
  4. {
  5. public function setUp()
  6. {
  7. $this->_attFile = dirname(__FILE__) . '/../../../_samples/files/textfile.zip';
  8. }
  9. public function testAttachmentSending()
  10. {
  11. $mailer = $this->_getMailer();
  12. $message = Swift_Message::newInstance()
  13. ->setSubject('[Swift Mailer] AttachmentSmokeTest')
  14. ->setFrom(array(SWIFT_SMOKE_EMAIL_ADDRESS => 'Swift Mailer'))
  15. ->setTo(SWIFT_SMOKE_EMAIL_ADDRESS)
  16. ->setBody('This message should contain an attached ZIP file (named "textfile.zip").' . PHP_EOL .
  17. 'When unzipped, the archive should produce a text file which reads:' . PHP_EOL .
  18. '"This is part of a Swift Mailer v4 smoke test."'
  19. )
  20. ->attach(Swift_Attachment::fromPath($this->_attFile))
  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. }