| 13532 |
anikendra |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* DebugTransportTest file
|
|
|
4 |
*
|
|
|
5 |
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
|
|
|
6 |
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
|
7 |
*
|
|
|
8 |
* Licensed under The MIT License
|
|
|
9 |
* For full copyright and license information, please see the LICENSE.txt
|
|
|
10 |
* Redistributions of files must retain the above copyright notice
|
|
|
11 |
*
|
|
|
12 |
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
|
13 |
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
|
|
|
14 |
* @package Cake.Test.Case.Network.Email
|
|
|
15 |
* @since CakePHP(tm) v 2.0.0
|
|
|
16 |
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
|
|
17 |
*/
|
|
|
18 |
|
|
|
19 |
App::uses('CakeEmail', 'Network/Email');
|
|
|
20 |
App::uses('AbstractTransport', 'Network/Email');
|
|
|
21 |
App::uses('DebugTransport', 'Network/Email');
|
|
|
22 |
|
|
|
23 |
/**
|
|
|
24 |
* Test case
|
|
|
25 |
*
|
|
|
26 |
*/
|
|
|
27 |
class DebugTransportTest extends CakeTestCase {
|
|
|
28 |
|
|
|
29 |
/**
|
|
|
30 |
* Setup
|
|
|
31 |
*
|
|
|
32 |
* @return void
|
|
|
33 |
*/
|
|
|
34 |
public function setUp() {
|
|
|
35 |
parent::setUp();
|
|
|
36 |
$this->DebugTransport = new DebugTransport();
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
/**
|
|
|
40 |
* testSend method
|
|
|
41 |
*
|
|
|
42 |
* @return void
|
|
|
43 |
*/
|
|
|
44 |
public function testSend() {
|
|
|
45 |
$this->getMock('CakeEmail', array('message'), array(), 'DebugCakeEmail');
|
|
|
46 |
$email = new DebugCakeEmail();
|
|
|
47 |
$email->from('noreply@cakephp.org', 'CakePHP Test');
|
|
|
48 |
$email->to('cake@cakephp.org', 'CakePHP');
|
|
|
49 |
$email->cc(array('mark@cakephp.org' => 'Mark Story', 'juan@cakephp.org' => 'Juan Basso'));
|
|
|
50 |
$email->bcc('phpnut@cakephp.org');
|
|
|
51 |
$email->messageID('<4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>');
|
|
|
52 |
$email->subject('Testing Message');
|
|
|
53 |
$date = date(DATE_RFC2822);
|
|
|
54 |
$email->setHeaders(array('X-Mailer' => DebugCakeEmail::EMAIL_CLIENT, 'Date' => $date));
|
|
|
55 |
$email->expects($this->any())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '.Third Line', '')));
|
|
|
56 |
|
|
|
57 |
$headers = "From: CakePHP Test <noreply@cakephp.org>\r\n";
|
|
|
58 |
$headers .= "To: CakePHP <cake@cakephp.org>\r\n";
|
|
|
59 |
$headers .= "Cc: Mark Story <mark@cakephp.org>, Juan Basso <juan@cakephp.org>\r\n";
|
|
|
60 |
$headers .= "X-Mailer: CakePHP Email\r\n";
|
|
|
61 |
$headers .= "Date: " . $date . "\r\n";
|
|
|
62 |
$headers .= "Message-ID: <4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>\r\n";
|
|
|
63 |
$headers .= "Subject: Testing Message\r\n";
|
|
|
64 |
$headers .= "MIME-Version: 1.0\r\n";
|
|
|
65 |
$headers .= "Content-Type: text/plain; charset=UTF-8\r\n";
|
|
|
66 |
$headers .= "Content-Transfer-Encoding: 8bit";
|
|
|
67 |
|
|
|
68 |
$data = "First Line\r\n";
|
|
|
69 |
$data .= "Second Line\r\n";
|
|
|
70 |
$data .= ".Third Line\r\n"; // Not use 'RFC5321 4.5.2.Transparency' in DebugTransport.
|
|
|
71 |
|
|
|
72 |
$result = $this->DebugTransport->send($email);
|
|
|
73 |
|
|
|
74 |
$this->assertEquals($headers, $result['headers']);
|
|
|
75 |
$this->assertEquals($data, $result['message']);
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
}
|