SmtpOfflineTest.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Mail
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * Zend_Mail
  24. */
  25. require_once 'Zend/Mail.php';
  26. /**
  27. * Zend_Mail_Protocol_Smtp
  28. */
  29. require_once 'Zend/Mail/Protocol/Smtp.php';
  30. /**
  31. * Zend_Mail_Transport_Smtp
  32. */
  33. require_once 'Zend/Mail/Transport/Smtp.php';
  34. /**
  35. * PHPUnit test case
  36. */
  37. require_once 'PHPUnit/Framework/TestCase.php';
  38. /**
  39. * Test helper for configuration when run standalone
  40. */
  41. require_once dirname(__FILE__) . '/../../TestHelper.php';
  42. /**
  43. * @category Zend
  44. * @package Zend_Mail
  45. * @subpackage UnitTests
  46. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  47. * @license http://framework.zend.com/license/new-bsd New BSD License
  48. * @group Zend_Mail
  49. */
  50. class Zend_Mail_SmtpOfflineTest extends PHPUnit_Framework_TestCase
  51. {
  52. protected $_params;
  53. public function setUp()
  54. {
  55. $this->_params = array('host' => TESTS_ZEND_MAIL_SMTP_HOST,
  56. 'port' => TESTS_ZEND_MAIL_SMTP_PORT,
  57. 'username' => TESTS_ZEND_MAIL_SMTP_USER,
  58. 'password' => TESTS_ZEND_MAIL_SMTP_PASSWORD,
  59. 'auth' => TESTS_ZEND_MAIL_SMTP_AUTH);
  60. }
  61. /**
  62. * @group ZF-8988
  63. */
  64. public function testReturnPathIsUsedAsMailFrom()
  65. {
  66. $connectionMock = $this->getMock('Zend_Mail_Protocol_Smtp');
  67. $connectionMock->expects($this->once())
  68. ->method('mail')
  69. ->with('return@example.com');
  70. $transport = new Zend_Mail_Transport_Smtp($this->_params['host'], $this->_params);
  71. $transport->setConnection($connectionMock);
  72. $mail = new Zend_Mail();
  73. $mail->setBodyText('This is a test.')
  74. ->setFrom('from@example.com', 'from user')
  75. ->setReturnPath('return@example.com');
  76. $mail->send($transport);
  77. }
  78. }