MailTransport.php #1

  • //
  • guest/
  • perforce_software/
  • chronicle/
  • main/
  • application/
  • workflow/
  • tests/
  • MailTransport.php
  • View
  • Commits
  • Open Download .zip Download (1 KB)
<?php
/**
 * Custom email transport for Zend_Mail primarily intended for testing.
 * No real emails are sent. Instead of that, emails that would normally
 * be sent by _sendEmail() method are saved in the register and values
 * can be checked by calling getSentMails().
 *
 * @copyright   2011 Perforce Software. All rights reserved.
 * @license     Please see LICENSE.txt in top-level folder of this distribution.
 * @version     <release>/<patch>
 */
class Workflow_Test_MailTransport extends Zend_Mail_Transport_Abstract
{
    protected $_sentMailsRegister = array();

    /**
     * Add email properties to the sent emails register.
     * Does not send any real email.
     */
    protected function _sendMail()
    {
        $this->_sentMailsRegister[] = array(
            'to'        => $this->recipients,
            'body'      => $this->body,
            'subject'   => $this->_mail->getSubject(),
            'headers'   => $this->_getHeaders(null),
        );
    }

    /**
     * Get list of emails registered by _sendMail() method since last reset.
     *
     * @return  array   list of emails registered by _sendMail() method.
     */
    public function getSentMails()
    {
        return $this->_sentMailsRegister;
    }

    /**
     * Reset sent emails register.
     */
    public function reset()
    {
        $this->_sentMailsRegister = array();
    }
}
# Change User Description Committed
#1 16170 perforce_software Move Chronicle files to follow new path scheme for branching.
//guest/perforce_software/chronicle/application/workflow/tests/MailTransport.php
#1 8972 Matt Attaway Initial add of the Chronicle source code