2011-06-17 22:21:31 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* DebugTransportTest file
|
|
|
|
*
|
2012-04-27 02:49:18 +00:00
|
|
|
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
|
2013-02-08 11:59:49 +00:00
|
|
|
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2011-06-17 22:21:31 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
2013-02-08 12:22:51 +00:00
|
|
|
* For full copyright and license information, please see the LICENSE.txt
|
2011-06-17 22:21:31 +00:00
|
|
|
* Redistributions of files must retain the above copyright notice
|
|
|
|
*
|
2013-02-08 11:59:49 +00:00
|
|
|
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2012-04-27 02:49:18 +00:00
|
|
|
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Test.Case.Network.Email
|
2011-06-17 22:21:31 +00:00
|
|
|
* @since CakePHP(tm) v 2.0.0
|
2013-05-30 22:11:14 +00:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
2011-06-17 22:21:31 +00:00
|
|
|
*/
|
2013-05-30 22:11:14 +00:00
|
|
|
|
2011-06-17 22:21:31 +00:00
|
|
|
App::uses('CakeEmail', 'Network/Email');
|
2011-08-29 09:38:01 +00:00
|
|
|
App::uses('AbstractTransport', 'Network/Email');
|
|
|
|
App::uses('DebugTransport', 'Network/Email');
|
2011-08-29 09:39:08 +00:00
|
|
|
|
2011-06-17 22:21:31 +00:00
|
|
|
/**
|
|
|
|
* Test case
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class DebugTransportTest extends CakeTestCase {
|
|
|
|
|
2011-08-29 09:38:01 +00:00
|
|
|
/**
|
|
|
|
* Setup
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setUp() {
|
2013-07-28 23:22:52 +00:00
|
|
|
parent::setUp();
|
2011-08-29 09:38:01 +00:00
|
|
|
$this->DebugTransport = new DebugTransport();
|
|
|
|
}
|
2011-06-17 22:21:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* testSend method
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testSend() {
|
2014-03-01 18:01:36 +00:00
|
|
|
$email = $this->getMock('CakeEmail', array('message'), array(), 'DebugCakeEmail');
|
2011-06-17 22:21:31 +00:00
|
|
|
$email->from('noreply@cakephp.org', 'CakePHP Test');
|
|
|
|
$email->to('cake@cakephp.org', 'CakePHP');
|
|
|
|
$email->cc(array('mark@cakephp.org' => 'Mark Story', 'juan@cakephp.org' => 'Juan Basso'));
|
|
|
|
$email->bcc('phpnut@cakephp.org');
|
|
|
|
$email->messageID('<4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>');
|
|
|
|
$email->subject('Testing Message');
|
2012-02-10 18:53:04 +00:00
|
|
|
$date = date(DATE_RFC2822);
|
2012-03-14 14:01:19 +00:00
|
|
|
$email->setHeaders(array('X-Mailer' => DebugCakeEmail::EMAIL_CLIENT, 'Date' => $date));
|
2014-03-01 18:01:36 +00:00
|
|
|
$email->expects($this->once())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '.Third Line', '')));
|
2011-06-17 22:21:31 +00:00
|
|
|
|
2011-08-26 00:31:18 +00:00
|
|
|
$headers = "From: CakePHP Test <noreply@cakephp.org>\r\n";
|
|
|
|
$headers .= "To: CakePHP <cake@cakephp.org>\r\n";
|
|
|
|
$headers .= "Cc: Mark Story <mark@cakephp.org>, Juan Basso <juan@cakephp.org>\r\n";
|
|
|
|
$headers .= "X-Mailer: CakePHP Email\r\n";
|
2012-02-10 18:53:04 +00:00
|
|
|
$headers .= "Date: " . $date . "\r\n";
|
2011-08-26 00:31:18 +00:00
|
|
|
$headers .= "Message-ID: <4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>\r\n";
|
|
|
|
$headers .= "Subject: Testing Message\r\n";
|
|
|
|
$headers .= "MIME-Version: 1.0\r\n";
|
|
|
|
$headers .= "Content-Type: text/plain; charset=UTF-8\r\n";
|
2011-10-22 13:23:50 +00:00
|
|
|
$headers .= "Content-Transfer-Encoding: 8bit";
|
2011-08-26 00:31:18 +00:00
|
|
|
|
2011-08-29 09:38:01 +00:00
|
|
|
$data = "First Line\r\n";
|
|
|
|
$data .= "Second Line\r\n";
|
2012-05-07 22:34:14 +00:00
|
|
|
$data .= ".Third Line\r\n"; // Not use 'RFC5321 4.5.2.Transparency' in DebugTransport.
|
2011-06-17 22:21:31 +00:00
|
|
|
|
2011-08-29 09:38:01 +00:00
|
|
|
$result = $this->DebugTransport->send($email);
|
2011-08-26 00:31:18 +00:00
|
|
|
|
|
|
|
$this->assertEquals($headers, $result['headers']);
|
|
|
|
$this->assertEquals($data, $result['message']);
|
2011-06-17 22:21:31 +00:00
|
|
|
}
|
|
|
|
|
2012-12-05 14:00:24 +00:00
|
|
|
}
|