EmbeddedFileTest.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. require_once 'Swift/Mime/EmbeddedFile.php';
  3. require_once 'Swift/Mime/AttachmentTest.php';
  4. require_once 'Swift/Mime/Grammar.php';
  5. class Swift_Mime_EmbeddedFileTest extends Swift_Mime_AttachmentTest
  6. {
  7. public function testNestingLevelIsAttachment()
  8. { //Overridden
  9. }
  10. public function testNestingLevelIsEmbedded()
  11. {
  12. $file = $this->_createEmbeddedFile($this->_createHeaderSet(),
  13. $this->_createEncoder(), $this->_createCache()
  14. );
  15. $this->assertEqual(
  16. Swift_Mime_MimeEntity::LEVEL_RELATED, $file->getNestingLevel()
  17. );
  18. }
  19. public function testIdIsAutoGenerated()
  20. {
  21. $headers = $this->_createHeaderSet(array(), false);
  22. $this->_checking(Expectations::create()
  23. -> one($headers)->addIdHeader('Content-ID', pattern('/^.*?@.*?$/D'))
  24. -> ignoring($headers)
  25. );
  26. $file = $this->_createEmbeddedFile($headers, $this->_createEncoder(),
  27. $this->_createCache()
  28. );
  29. }
  30. public function testDefaultDispositionIsAttachment()
  31. { //Overridden
  32. }
  33. public function testDefaultDispositionIsInline()
  34. {
  35. $headers = $this->_createHeaderSet(array(), false);
  36. $this->_checking(Expectations::create()
  37. -> one($headers)->addParameterizedHeader('Content-Disposition', 'inline')
  38. -> ignoring($headers)
  39. );
  40. $file = $this->_createEmbeddedFile($headers, $this->_createEncoder(),
  41. $this->_createCache()
  42. );
  43. }
  44. // -- Private helpers
  45. protected function _createAttachment($headers, $encoder, $cache,
  46. $mimeTypes = array())
  47. {
  48. return $this->_createEmbeddedFile($headers, $encoder, $cache, $mimeTypes);
  49. }
  50. private function _createEmbeddedFile($headers, $encoder, $cache)
  51. {
  52. return new Swift_Mime_EmbeddedFile($headers, $encoder, $cache, new Swift_Mime_Grammar());
  53. }
  54. }