This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 111
/
SmtpTest.php
79 lines (70 loc) · 2.49 KB
/
SmtpTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Mail
*/
namespace ZendTest\Mail\Protocol;
use Zend\Mail\Headers;
use Zend\Mail\Message;
use Zend\Mail\Transport\Smtp;
use ZendTest\Mail\TestAsset\SmtpProtocolSpy;
/**
* @category Zend
* @package Zend_Mail
* @subpackage UnitTests
* @group Zend_Mail
*/
class SmtpTest extends \PHPUnit_Framework_TestCase
{
/** @var Smtp */
public $transport;
/** @var SmtpProtocolSpy */
public $connection;
public function setUp()
{
$this->transport = new Smtp();
$this->connection = new SmtpProtocolSpy();
$this->transport->setConnection($this->connection);
}
public function testSendMinimalMail()
{
$headers = new Headers();
$headers->addHeaderLine('Date', 'Sun, 10 Jun 2012 20:07:24 +0200');
$message = new Message();
$message
->setHeaders($headers)
->setSender('ralph.schindler@zend.com', 'Ralph Schindler')
->setBody('testSendMailWithoutMinimalHeaders')
->addTo('zf-devteam@zend.com', 'ZF DevTeam')
;
$expectedMessage = "EHLO localhost\r\n"
. "MAIL FROM:<ralph.schindler@zend.com>\r\n"
. "DATA\r\n"
. "Date: Sun, 10 Jun 2012 20:07:24 +0200\r\n"
. "Sender: Ralph Schindler <ralph.schindler@zend.com>\r\n"
. "To: ZF DevTeam <zf-devteam@zend.com>\r\n"
. "\r\n"
. "testSendMailWithoutMinimalHeaders\r\n"
. ".\r\n";
$this->transport->send($message);
$this->assertEquals($expectedMessage, $this->connection->getLog());
}
public function testDisconnectCallsQuit()
{
$this->connection->disconnect();
$this->assertTrue($this->connection->calledQuit);
}
public function testDisconnectResetsAuthFlag()
{
$this->connection->connect();
$this->connection->setSessionStatus(true);
$this->connection->setAuth(true);
$this->assertTrue($this->connection->getAuth());
$this->connection->disconnect();
$this->assertFalse($this->connection->getAuth());
}
}