mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-08-03 14:43:49 +02:00
Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
parent
5a580df460
commit
235a541597
793 changed files with 60746 additions and 23753 deletions
File diff suppressed because it is too large
Load diff
|
@ -2,27 +2,26 @@
|
|||
/**
|
||||
* DebugTransportTest file
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
|
||||
* @package Cake.Test.Case.Network.Email
|
||||
* @since CakePHP(tm) v 2.0.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('CakeEmail', 'Network/Email');
|
||||
App::uses('AbstractTransport', 'Network/Email');
|
||||
App::uses('DebugTransport', 'Network/Email');
|
||||
|
||||
/**
|
||||
* Test case
|
||||
*
|
||||
*/
|
||||
class DebugTransportTest extends CakeTestCase {
|
||||
|
||||
|
@ -32,6 +31,7 @@ class DebugTransportTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->DebugTransport = new DebugTransport();
|
||||
}
|
||||
|
||||
|
@ -41,8 +41,7 @@ class DebugTransportTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testSend() {
|
||||
$this->getMock('CakeEmail', array('message'), array(), 'DebugCakeEmail');
|
||||
$email = new DebugCakeEmail();
|
||||
$email = $this->getMock('CakeEmail', array('message'), array(), 'DebugCakeEmail');
|
||||
$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'));
|
||||
|
@ -51,7 +50,7 @@ class DebugTransportTest extends CakeTestCase {
|
|||
$email->subject('Testing Message');
|
||||
$date = date(DATE_RFC2822);
|
||||
$email->setHeaders(array('X-Mailer' => DebugCakeEmail::EMAIL_CLIENT, 'Date' => $date));
|
||||
$email->expects($this->any())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '.Third Line', '')));
|
||||
$email->expects($this->once())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '.Third Line', '')));
|
||||
|
||||
$headers = "From: CakePHP Test <noreply@cakephp.org>\r\n";
|
||||
$headers .= "To: CakePHP <cake@cakephp.org>\r\n";
|
||||
|
@ -74,4 +73,4 @@ class DebugTransportTest extends CakeTestCase {
|
|||
$this->assertEquals($data, $result['message']);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,28 +2,26 @@
|
|||
/**
|
||||
* MailTransportTest file
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
|
||||
* @package Cake.Test.Case.Network.Email
|
||||
* @since CakePHP(tm) v 2.0.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('CakeEmail', 'Network/Email');
|
||||
App::uses('AbstractTransport', 'Network/Email');
|
||||
App::uses('MailTransport', 'Network/Email');
|
||||
|
||||
|
||||
/**
|
||||
* Test case
|
||||
*
|
||||
*/
|
||||
class MailTransportTest extends CakeTestCase {
|
||||
|
||||
|
@ -33,6 +31,7 @@ class MailTransportTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->MailTransport = $this->getMock('MailTransport', array('_mail'));
|
||||
$this->MailTransport->config(array('additionalParameters' => '-f'));
|
||||
}
|
||||
|
@ -50,10 +49,19 @@ class MailTransportTest extends CakeTestCase {
|
|||
$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('Foø Bår Béz Foø Bår Béz Foø Bår Béz Foø Bår Béz');
|
||||
$longNonAscii = 'Foø Bår Béz Foø Bår Béz Foø Bår Béz Foø Bår Béz';
|
||||
$email->subject($longNonAscii);
|
||||
$date = date(DATE_RFC2822);
|
||||
$email->setHeaders(array('X-Mailer' => 'CakePHP Email', 'Date' => $date));
|
||||
$email->expects($this->any())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '.Third Line', '')));
|
||||
$email->setHeaders(array(
|
||||
'X-Mailer' => 'CakePHP Email',
|
||||
'Date' => $date,
|
||||
'X-add' => mb_encode_mimeheader($longNonAscii, 'utf8', 'B'),
|
||||
));
|
||||
$email->expects($this->any())->method('message')
|
||||
->will($this->returnValue(array('First Line', 'Second Line', '.Third Line', '')));
|
||||
|
||||
$encoded = '=?UTF-8?B?Rm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXog?=';
|
||||
$encoded .= ' =?UTF-8?B?Rm/DuCBCw6VyIELDqXo=?=';
|
||||
|
||||
$data = "From: CakePHP Test <noreply@cakephp.org>" . PHP_EOL;
|
||||
$data .= "Return-Path: CakePHP Return <pleasereply@cakephp.org>" . PHP_EOL;
|
||||
|
@ -61,24 +69,25 @@ class MailTransportTest extends CakeTestCase {
|
|||
$data .= "Bcc: phpnut@cakephp.org" . PHP_EOL;
|
||||
$data .= "X-Mailer: CakePHP Email" . PHP_EOL;
|
||||
$data .= "Date: " . $date . PHP_EOL;
|
||||
$data .= "X-add: " . $encoded . PHP_EOL;
|
||||
$data .= "Message-ID: <4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>" . PHP_EOL;
|
||||
$data .= "MIME-Version: 1.0" . PHP_EOL;
|
||||
$data .= "Content-Type: text/plain; charset=UTF-8" . PHP_EOL;
|
||||
$data .= "Content-Transfer-Encoding: 8bit";
|
||||
|
||||
$subject = '=?UTF-8?B?Rm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXog?=';
|
||||
$subject .= "\r\n" . ' =?UTF-8?B?Rm/DuCBCw6VyIELDqXo=?=';
|
||||
$this->MailTransport->expects($this->once())->method('_mail')
|
||||
->with(
|
||||
'CakePHP <cake@cakephp.org>',
|
||||
$subject,
|
||||
$encoded,
|
||||
implode(PHP_EOL, array('First Line', 'Second Line', '.Third Line', '')),
|
||||
$data,
|
||||
'-f'
|
||||
);
|
||||
|
||||
$this->MailTransport->send($email);
|
||||
$result = $this->MailTransport->send($email);
|
||||
|
||||
$this->assertContains('Subject: ', $result['headers']);
|
||||
$this->assertContains('To: ', $result['headers']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -2,50 +2,39 @@
|
|||
/**
|
||||
* SmtpTransportTest file
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
|
||||
* @package Cake.Test.Case.Network.Email
|
||||
* @since CakePHP(tm) v 2.0.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('CakeEmail', 'Network/Email');
|
||||
App::uses('AbstractTransport', 'Network/Email');
|
||||
App::uses('SmtpTransport', 'Network/Email');
|
||||
|
||||
/**
|
||||
* Help to test SmtpTransport
|
||||
*
|
||||
*/
|
||||
class SmtpTestTransport extends SmtpTransport {
|
||||
|
||||
/**
|
||||
* Helper to change the socket
|
||||
*
|
||||
* @param object $socket
|
||||
* @param CakeSocket $socket A socket.
|
||||
* @return void
|
||||
*/
|
||||
public function setSocket(CakeSocket $socket) {
|
||||
$this->_socket = $socket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to change the CakeEmail
|
||||
*
|
||||
* @param object $cakeEmail
|
||||
* @return void
|
||||
*/
|
||||
public function setCakeEmail($cakeEmail) {
|
||||
$this->_cakeEmail = $cakeEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disabled the socket change
|
||||
*
|
||||
|
@ -57,20 +46,19 @@ class SmtpTestTransport extends SmtpTransport {
|
|||
/**
|
||||
* Magic function to call protected methods
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $args
|
||||
* @param string $method The method to call.
|
||||
* @param string $args The arguments.
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $args) {
|
||||
$method = '_' . $method;
|
||||
return $this->$method();
|
||||
return call_user_func_array(array($this, $method), $args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case
|
||||
*
|
||||
*/
|
||||
class SmtpTransportTest extends CakeTestCase {
|
||||
|
||||
|
@ -80,10 +68,8 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function setUp() {
|
||||
if (!class_exists('MockSocket')) {
|
||||
$this->getMock('CakeSocket', array('read', 'write', 'connect'), array(), 'MockSocket');
|
||||
}
|
||||
$this->socket = new MockSocket();
|
||||
parent::setUp();
|
||||
$this->socket = $this->getMock('CakeSocket', array('read', 'write', 'connect', 'enableCrypto'));
|
||||
|
||||
$this->SmtpTransport = new SmtpTestTransport();
|
||||
$this->SmtpTransport->setSocket($this->socket);
|
||||
|
@ -105,6 +91,72 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
$this->SmtpTransport->connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* testConnectEhloTls method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConnectEhloTls() {
|
||||
$this->SmtpTransport->config(array('tls' => true));
|
||||
$this->socket->expects($this->any())->method('connect')->will($this->returnValue(true));
|
||||
$this->socket->expects($this->at(0))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n"));
|
||||
$this->socket->expects($this->at(2))->method('write')->with("EHLO localhost\r\n");
|
||||
$this->socket->expects($this->at(3))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(4))->method('read')->will($this->returnValue("250 Accepted\r\n"));
|
||||
$this->socket->expects($this->at(5))->method('write')->with("STARTTLS\r\n");
|
||||
$this->socket->expects($this->at(6))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(7))->method('read')->will($this->returnValue("220 Server ready\r\n"));
|
||||
$this->socket->expects($this->at(8))->method('enableCrypto')->with('tls')->will($this->returnValue(true));
|
||||
$this->socket->expects($this->at(9))->method('write')->with("EHLO localhost\r\n");
|
||||
$this->socket->expects($this->at(10))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(11))->method('read')->will($this->returnValue("250 Accepted\r\n"));
|
||||
$this->SmtpTransport->connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* testConnectEhloTlsOnNonTlsServer method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage SMTP server did not accept the connection or trying to connect to non TLS SMTP server using TLS.
|
||||
* @return void
|
||||
*/
|
||||
public function testConnectEhloTlsOnNonTlsServer() {
|
||||
$this->SmtpTransport->config(array('tls' => true));
|
||||
$this->socket->expects($this->any())->method('connect')->will($this->returnValue(true));
|
||||
$this->socket->expects($this->at(0))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n"));
|
||||
$this->socket->expects($this->at(2))->method('write')->with("EHLO localhost\r\n");
|
||||
$this->socket->expects($this->at(3))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(4))->method('read')->will($this->returnValue("250 Accepted\r\n"));
|
||||
$this->socket->expects($this->at(5))->method('write')->with("STARTTLS\r\n");
|
||||
$this->socket->expects($this->at(6))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(7))->method('read')->will($this->returnValue("500 5.3.3 Unrecognized command\r\n"));
|
||||
$this->SmtpTransport->connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* testConnectEhloNoTlsOnRequiredTlsServer method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage SMTP authentication method not allowed, check if SMTP server requires TLS.
|
||||
* @return void
|
||||
*/
|
||||
public function testConnectEhloNoTlsOnRequiredTlsServer() {
|
||||
$this->SmtpTransport->config(array('tls' => false, 'username' => 'user', 'password' => 'pass'));
|
||||
$this->socket->expects($this->any())->method('connect')->will($this->returnValue(true));
|
||||
$this->socket->expects($this->at(0))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n"));
|
||||
$this->socket->expects($this->at(2))->method('write')->with("EHLO localhost\r\n");
|
||||
$this->socket->expects($this->at(3))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(4))->method('read')->will($this->returnValue("250 Accepted\r\n"));
|
||||
$this->socket->expects($this->at(5))->method('write')->with("AUTH LOGIN\r\n");
|
||||
$this->socket->expects($this->at(6))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(7))->method('read')->will($this->returnValue("504 5.7.4 Unrecognized authentication type\r\n"));
|
||||
$this->SmtpTransport->connect();
|
||||
$this->SmtpTransport->auth();
|
||||
}
|
||||
|
||||
/**
|
||||
* testConnectHelo method
|
||||
*
|
||||
|
@ -127,6 +179,7 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
* testConnectFail method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage SMTP server did not accept the connection.
|
||||
* @return void
|
||||
*/
|
||||
public function testConnectFail() {
|
||||
|
@ -161,13 +214,98 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
$this->SmtpTransport->auth();
|
||||
}
|
||||
|
||||
/**
|
||||
* testAuthNotRecognized method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage AUTH command not recognized or not implemented, SMTP server may not require authentication.
|
||||
* @return void
|
||||
*/
|
||||
public function testAuthNotRecognized() {
|
||||
$this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(2))->method('read')->will($this->returnValue("500 5.3.3 Unrecognized command\r\n"));
|
||||
$this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story'));
|
||||
$this->SmtpTransport->auth();
|
||||
}
|
||||
|
||||
/**
|
||||
* testAuthNotImplemented method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage AUTH command not recognized or not implemented, SMTP server may not require authentication.
|
||||
* @return void
|
||||
*/
|
||||
public function testAuthNotImplemented() {
|
||||
$this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(2))->method('read')->will($this->returnValue("502 5.3.3 Command not implemented\r\n"));
|
||||
$this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story'));
|
||||
$this->SmtpTransport->auth();
|
||||
}
|
||||
|
||||
/**
|
||||
* testAuthBadSequence method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage SMTP Error: 503 5.5.1 Already authenticated
|
||||
* @return void
|
||||
*/
|
||||
public function testAuthBadSequence() {
|
||||
$this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(2))->method('read')->will($this->returnValue("503 5.5.1 Already authenticated\r\n"));
|
||||
$this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story'));
|
||||
$this->SmtpTransport->auth();
|
||||
}
|
||||
|
||||
/**
|
||||
* testAuthBadUsername method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage SMTP server did not accept the username.
|
||||
* @return void
|
||||
*/
|
||||
public function testAuthBadUsername() {
|
||||
$this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(2))->method('read')->will($this->returnValue("334 Login\r\n"));
|
||||
$this->socket->expects($this->at(3))->method('write')->with("bWFyaw==\r\n");
|
||||
$this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(5))->method('read')->will($this->returnValue("535 5.7.8 Authentication failed\r\n"));
|
||||
$this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story'));
|
||||
$this->SmtpTransport->auth();
|
||||
}
|
||||
|
||||
/**
|
||||
* testAuthBadPassword method
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage SMTP server did not accept the password.
|
||||
* @return void
|
||||
*/
|
||||
public function testAuthBadPassword() {
|
||||
$this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(2))->method('read')->will($this->returnValue("334 Login\r\n"));
|
||||
$this->socket->expects($this->at(3))->method('write')->with("bWFyaw==\r\n");
|
||||
$this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(5))->method('read')->will($this->returnValue("334 Pass\r\n"));
|
||||
$this->socket->expects($this->at(6))->method('write')->with("c3Rvcnk=\r\n");
|
||||
$this->socket->expects($this->at(7))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(8))->method('read')->will($this->returnValue("535 5.7.8 Authentication failed\r\n"));
|
||||
$this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story'));
|
||||
$this->SmtpTransport->auth();
|
||||
}
|
||||
|
||||
/**
|
||||
* testAuthNoAuth method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAuthNoAuth() {
|
||||
$this->socket->expects($this->never())->method('write')->with("AUTH LOGIN\r\n");
|
||||
$this->socket->expects($this->any())->method('write')->with($this->logicalNot($this->stringContains('AUTH LOGIN')));
|
||||
|
||||
$this->SmtpTransport->config(array('username' => null, 'password' => null));
|
||||
$this->SmtpTransport->auth();
|
||||
}
|
||||
|
@ -200,8 +338,28 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
$this->socket->expects($this->at(13))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(14))->method('read')->will($this->returnValue("250 OK\r\n"));
|
||||
|
||||
$this->SmtpTransport->setCakeEmail($email);
|
||||
$this->SmtpTransport->sendRcpt();
|
||||
$this->SmtpTransport->sendRcpt($email);
|
||||
}
|
||||
|
||||
/**
|
||||
* testRcptWithReturnPath method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRcptWithReturnPath() {
|
||||
$email = new CakeEmail();
|
||||
$email->from('noreply@cakephp.org', 'CakePHP Test');
|
||||
$email->to('cake@cakephp.org', 'CakePHP');
|
||||
$email->returnPath('pleasereply@cakephp.org', 'CakePHP Return');
|
||||
|
||||
$this->socket->expects($this->at(0))->method('write')->with("MAIL FROM:<pleasereply@cakephp.org>\r\n");
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(2))->method('read')->will($this->returnValue("250 OK\r\n"));
|
||||
$this->socket->expects($this->at(3))->method('write')->with("RCPT TO:<cake@cakephp.org>\r\n");
|
||||
$this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(5))->method('read')->will($this->returnValue("250 OK\r\n"));
|
||||
|
||||
$this->SmtpTransport->sendRcpt($email);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -210,8 +368,7 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testSendData() {
|
||||
$this->getMock('CakeEmail', array('message'), array(), 'SmtpCakeEmail');
|
||||
$email = new SmtpCakeEmail();
|
||||
$email = $this->getMock('CakeEmail', array('message'), array(), 'SmtpCakeEmail');
|
||||
$email->from('noreply@cakephp.org', 'CakePHP Test');
|
||||
$email->returnPath('pleasereply@cakephp.org', 'CakePHP Return');
|
||||
$email->to('cake@cakephp.org', 'CakePHP');
|
||||
|
@ -221,10 +378,9 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
$email->subject('Testing SMTP');
|
||||
$date = date(DATE_RFC2822);
|
||||
$email->setHeaders(array('X-Mailer' => SmtpCakeEmail::EMAIL_CLIENT, 'Date' => $date));
|
||||
$email->expects($this->any())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '.Third Line', '')));
|
||||
$email->expects($this->once())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '.Third Line', '')));
|
||||
|
||||
$data = "From: CakePHP Test <noreply@cakephp.org>\r\n";
|
||||
$data .= "Return-Path: CakePHP Return <pleasereply@cakephp.org>\r\n";
|
||||
$data .= "To: CakePHP <cake@cakephp.org>\r\n";
|
||||
$data .= "Cc: Mark Story <mark@cakephp.org>, Juan Basso <juan@cakephp.org>\r\n";
|
||||
$data .= "X-Mailer: CakePHP Email\r\n";
|
||||
|
@ -248,8 +404,7 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
$this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(5))->method('read')->will($this->returnValue("250 OK\r\n"));
|
||||
|
||||
$this->SmtpTransport->setCakeEmail($email);
|
||||
$this->SmtpTransport->sendData();
|
||||
$this->SmtpTransport->sendData($email);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -262,4 +417,108 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
$this->SmtpTransport->disconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
* testEmptyConfigArray method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEmptyConfigArray() {
|
||||
$expected = $this->SmtpTransport->config(array(
|
||||
'client' => 'myhost.com',
|
||||
'port' => 666
|
||||
));
|
||||
|
||||
$this->assertEquals(666, $expected['port']);
|
||||
|
||||
$result = $this->SmtpTransport->config(array());
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testGetLastResponse method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetLastResponse() {
|
||||
$this->assertEmpty($this->SmtpTransport->getLastResponse());
|
||||
|
||||
$this->socket->expects($this->any())->method('connect')->will($this->returnValue(true));
|
||||
$this->socket->expects($this->at(0))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n"));
|
||||
$this->socket->expects($this->at(2))->method('write')->with("EHLO localhost\r\n");
|
||||
$this->socket->expects($this->at(3))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(4))->method('read')->will($this->returnValue("250-PIPELINING\r\n"));
|
||||
$this->socket->expects($this->at(5))->method('read')->will($this->returnValue("250-SIZE 102400000\r\n"));
|
||||
$this->socket->expects($this->at(6))->method('read')->will($this->returnValue("250-VRFY\r\n"));
|
||||
$this->socket->expects($this->at(7))->method('read')->will($this->returnValue("250-ETRN\r\n"));
|
||||
$this->socket->expects($this->at(8))->method('read')->will($this->returnValue("250-STARTTLS\r\n"));
|
||||
$this->socket->expects($this->at(9))->method('read')->will($this->returnValue("250-AUTH PLAIN LOGIN\r\n"));
|
||||
$this->socket->expects($this->at(10))->method('read')->will($this->returnValue("250-AUTH=PLAIN LOGIN\r\n"));
|
||||
$this->socket->expects($this->at(11))->method('read')->will($this->returnValue("250-ENHANCEDSTATUSCODES\r\n"));
|
||||
$this->socket->expects($this->at(12))->method('read')->will($this->returnValue("250-8BITMIME\r\n"));
|
||||
$this->socket->expects($this->at(13))->method('read')->will($this->returnValue("250 DSN\r\n"));
|
||||
$this->SmtpTransport->connect();
|
||||
|
||||
$expected = array(
|
||||
array('code' => '250', 'message' => 'PIPELINING'),
|
||||
array('code' => '250', 'message' => 'SIZE 102400000'),
|
||||
array('code' => '250', 'message' => 'VRFY'),
|
||||
array('code' => '250', 'message' => 'ETRN'),
|
||||
array('code' => '250', 'message' => 'STARTTLS'),
|
||||
array('code' => '250', 'message' => 'AUTH PLAIN LOGIN'),
|
||||
array('code' => '250', 'message' => 'AUTH=PLAIN LOGIN'),
|
||||
array('code' => '250', 'message' => 'ENHANCEDSTATUSCODES'),
|
||||
array('code' => '250', 'message' => '8BITMIME'),
|
||||
array('code' => '250', 'message' => 'DSN')
|
||||
);
|
||||
$result = $this->SmtpTransport->getLastResponse();
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$email = new CakeEmail();
|
||||
$email->from('noreply@cakephp.org', 'CakePHP Test');
|
||||
$email->to('cake@cakephp.org', 'CakePHP');
|
||||
|
||||
$this->socket->expects($this->at(0))->method('write')->with("MAIL FROM:<noreply@cakephp.org>\r\n");
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(2))->method('read')->will($this->returnValue("250 OK\r\n"));
|
||||
$this->socket->expects($this->at(3))->method('write')->with("RCPT TO:<cake@cakephp.org>\r\n");
|
||||
$this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(5))->method('read')->will($this->returnValue("250 OK\r\n"));
|
||||
|
||||
$this->SmtpTransport->sendRcpt($email);
|
||||
|
||||
$expected = array(
|
||||
array('code' => '250', 'message' => 'OK'),
|
||||
);
|
||||
$result = $this->SmtpTransport->getLastResponse();
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testBufferResponseLines method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBufferResponseLines() {
|
||||
$reponseLines = array(
|
||||
'123',
|
||||
"456\tFOO",
|
||||
'FOOBAR',
|
||||
'250-PIPELINING',
|
||||
'250-ENHANCEDSTATUSCODES',
|
||||
'250-8BITMIME',
|
||||
'250 DSN',
|
||||
);
|
||||
$this->SmtpTransport->bufferResponseLines($reponseLines);
|
||||
|
||||
$expected = array(
|
||||
array('code' => '123', 'message' => null),
|
||||
array('code' => '250', 'message' => 'PIPELINING'),
|
||||
array('code' => '250', 'message' => 'ENHANCEDSTATUSCODES'),
|
||||
array('code' => '250', 'message' => '8BITMIME'),
|
||||
array('code' => '250', 'message' => 'DSN')
|
||||
);
|
||||
$result = $this->SmtpTransport->getLastResponse();
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue