SmtpOfflineTest.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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-2015 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. * @category Zend
  36. * @package Zend_Mail
  37. * @subpackage UnitTests
  38. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  39. * @license http://framework.zend.com/license/new-bsd New BSD License
  40. * @group Zend_Mail
  41. */
  42. class Zend_Mail_SmtpOfflineTest extends PHPUnit_Framework_TestCase
  43. {
  44. protected $_params;
  45. public function setUp()
  46. {
  47. $this->_params = array('host' => TESTS_ZEND_MAIL_SMTP_HOST,
  48. 'port' => TESTS_ZEND_MAIL_SMTP_PORT,
  49. 'username' => TESTS_ZEND_MAIL_SMTP_USER,
  50. 'password' => TESTS_ZEND_MAIL_SMTP_PASSWORD,
  51. 'auth' => TESTS_ZEND_MAIL_SMTP_AUTH);
  52. }
  53. /**
  54. * @group ZF-8988
  55. */
  56. public function testReturnPathIsUsedAsMailFrom()
  57. {
  58. $connectionMock = $this->getMock('Zend_Mail_Protocol_Smtp');
  59. $connectionMock->expects($this->once())
  60. ->method('mail')
  61. ->with('return@example.com');
  62. $transport = new Zend_Mail_Transport_Smtp($this->_params['host'], $this->_params);
  63. $transport->setConnection($connectionMock);
  64. $mail = new Zend_Mail();
  65. $mail->setBodyText('This is a test.')
  66. ->setFrom('from@example.com', 'from user')
  67. ->setReturnPath('return@example.com');
  68. $mail->send($transport);
  69. }
  70. }