Переглянути джерело

ZF-8988: Applying patch from Marc Hodgins

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23423 44c647ce-9c0f-0410-b52a-842ac1e357ba
bittarman 15 роки тому
батько
коміт
a541dbb6b8

+ 1 - 1
library/Zend/Mail/Transport/Smtp.php

@@ -204,7 +204,7 @@ class Zend_Mail_Transport_Smtp extends Zend_Mail_Transport_Abstract
         }
 
         // Set sender email address
-        $this->_connection->mail($this->_mail->getFrom());
+        $this->_connection->mail($this->_mail->getReturnPath());
 
         // Set recipient forward paths
         foreach ($this->_mail->getRecipients() as $recipient) {

+ 2 - 0
tests/Zend/Mail/AllTests.php

@@ -38,6 +38,7 @@ require_once 'Zend/Mail/Pop3Test.php';
 require_once 'Zend/Mail/ImapTest.php';
 require_once 'Zend/Mail/InterfaceTest.php';
 require_once 'Zend/Mail/MessageTest.php';
+require_once 'Zend/Mail/SmtpOfflineTest.php';
 require_once 'Zend/Mail/SmtpTest.php';
 require_once 'Zend/Mail/FileTransportTest.php';
 
@@ -78,6 +79,7 @@ class Zend_Mail_AllTests
             $suite->addTestSuite('Zend_Mail_MaildirFolderTest');
             $suite->addTestSuite('Zend_Mail_MaildirWritableTest');
         }
+	$suite->addTestSuite('Zend_Mail_SmtpOfflineTest');
         if (defined('TESTS_ZEND_MAIL_SMTP_ENABLED') && constant('TESTS_ZEND_MAIL_SMTP_ENABLED') == true) {
             $suite->addTestSuite('Zend_Mail_SmtpTest');
         }

+ 91 - 0
tests/Zend/Mail/SmtpOfflineTest.php

@@ -0,0 +1,91 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Mail
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id$
+ */
+
+/** 
+ * Zend_Mail
+ */
+require_once 'Zend/Mail.php';
+
+/**
+ * Zend_Mail_Protocol_Smtp
+ */
+require_once 'Zend/Mail/Protocol/Smtp.php';
+
+
+/**
+ * Zend_Mail_Transport_Smtp
+ */
+require_once 'Zend/Mail/Transport/Smtp.php';
+
+
+/**
+ * PHPUnit test case
+ */
+require_once 'PHPUnit/Framework/TestCase.php';
+
+/**
+ * Test helper for configuration when run standalone
+ */
+require_once dirname(__FILE__) . '/../../TestHelper.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Mail
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @group      Zend_Mail
+ */
+class Zend_Mail_SmtpOfflineTest extends PHPUnit_Framework_TestCase
+{
+    protected $_params;
+
+    public function setUp()
+    {
+        $this->_params = array('host'     => TESTS_ZEND_MAIL_SMTP_HOST,
+                               'port'     => TESTS_ZEND_MAIL_SMTP_PORT,
+                               'username' => TESTS_ZEND_MAIL_SMTP_USER,
+                               'password' => TESTS_ZEND_MAIL_SMTP_PASSWORD,
+                               'auth'     => TESTS_ZEND_MAIL_SMTP_AUTH);
+    }
+
+    /**
+     * @group ZF-8988
+     */
+    public function testReturnPathIsUsedAsMailFrom()
+    {
+        $connectionMock = $this->getMock('Zend_Mail_Protocol_Smtp');
+        $connectionMock->expects($this->once())
+                       ->method('mail')
+                       ->with('return@example.com');
+
+        $transport = new Zend_Mail_Transport_Smtp($this->_params['host'], $this->_params);
+        $transport->setConnection($connectionMock);
+
+        $mail = new Zend_Mail();
+        $mail->setBodyText('This is a test.')
+             ->setFrom('from@example.com', 'from user')
+             ->setReturnPath('return@example.com');
+
+        $mail->send($transport);
+    }
+}

+ 5 - 0
tests/Zend/Mail/SmtpTest.php

@@ -38,6 +38,11 @@ require_once 'Zend/Mail/Transport/Smtp.php';
 require_once 'PHPUnit/Framework/TestCase.php';
 
 /**
+ * Test helper for configuration when run standalone
+ */
+require_once dirname(__FILE__).'/../../TestHelper.php';
+
+/**
  * @category   Zend
  * @package    Zend_Mail
  * @subpackage UnitTests