17
17
use Symfony \Component \Mime \Header \Headers ;
18
18
use Symfony \Component \Mime \Message ;
19
19
use Symfony \Component \Mime \NamedAddress ;
20
- use Symfony \Component \Mime \RawMessage ;
21
20
22
21
class SmtpEnvelopeTest extends TestCase
23
22
{
@@ -54,19 +53,19 @@ public function testConstructorWithWrongRecipients()
54
53
public function testSenderFromHeaders ()
55
54
{
56
55
$ headers = new Headers ();
57
- $ headers->
addPathHeader (
'Return-Path ' ,
'[email protected] ' );
56
+ $ headers->
addPathHeader (
'Return-Path ' ,
new NamedAddress ( '[email protected] ' , ' return ' ) );
58
57
$ headers->
addMailboxListHeader (
'To ' , [
'[email protected] ' ]);
59
58
$ e = SmtpEnvelope::create (new Message ($ headers ));
60
59
$ this ->
assertEquals (
'[email protected] ' ,
$ e->
getSender ()->
getAddress ());
61
60
62
61
$ headers = new Headers ();
63
- $ headers->
addMailboxHeader (
'Sender ' ,
'[email protected] ' );
62
+ $ headers->
addMailboxHeader (
'Sender ' ,
new NamedAddress ( '[email protected] ' , ' sender ' ) );
64
63
$ headers->
addMailboxListHeader (
'To ' , [
'[email protected] ' ]);
65
64
$ e = SmtpEnvelope::create (new Message ($ headers ));
66
65
$ this ->
assertEquals (
'[email protected] ' ,
$ e->
getSender ()->
getAddress ());
67
66
68
67
$ headers = new Headers ();
69
- $ headers->
addMailboxListHeader (
'From ' , [
'[email protected] ' ,
'[email protected] ' ]);
68
+ $ headers->
addMailboxListHeader (
'From ' , [
new NamedAddress ( '[email protected] ' , ' from ' ) ,
'[email protected] ' ]);
70
69
$ headers->
addMailboxListHeader (
'To ' , [
'[email protected] ' ]);
71
70
$ e = SmtpEnvelope::create (new Message ($ headers ));
72
71
$ this ->
assertEquals (
'[email protected] ' ,
$ e->
getSender ()->
getAddress ());
@@ -77,17 +76,17 @@ public function testSenderFromHeadersWithoutFrom()
77
76
$ headers = new Headers ();
78
77
$ headers->
addMailboxListHeader (
'To ' , [
'[email protected] ' ]);
79
78
$ e = SmtpEnvelope::create ($ message = new Message ($ headers ));
80
- $ message->
getHeaders ()->
addMailboxListHeader (
'From ' , [
'[email protected] ' ]);
79
+ $ message->
getHeaders ()->
addMailboxListHeader (
'From ' , [
new NamedAddress ( '[email protected] ' , ' from ' ) ]);
81
80
$ this ->
assertEquals (
'[email protected] ' ,
$ e->
getSender ()->
getAddress ());
82
81
}
83
82
84
83
public function testRecipientsFromHeaders ()
85
84
{
86
85
$ headers = new Headers ();
87
86
$ headers->
addPathHeader (
'Return-Path ' ,
'[email protected] ' );
88
- $ headers->
addMailboxListHeader (
'To ' , [
'[email protected] ' ]);
89
- $ headers->
addMailboxListHeader (
'Cc ' , [
'[email protected] ' ]);
90
- $ headers->
addMailboxListHeader (
'Bcc ' , [
'[email protected] ' ]);
87
+ $ headers->
addMailboxListHeader (
'To ' , [
new NamedAddress ( '[email protected] ' , ' to ' ) ]);
88
+ $ headers->
addMailboxListHeader (
'Cc ' , [
new NamedAddress ( '[email protected] ' , ' cc ' ) ]);
89
+ $ headers->
addMailboxListHeader (
'Bcc ' , [
new NamedAddress ( '[email protected] ' , ' bcc ' ) ]);
91
90
$ e = SmtpEnvelope::create (new Message ($ headers ));
92
91
$ this ->
assertEquals ([
new Address (
'[email protected] ' ),
new Address (
'[email protected] ' ),
new Address (
'[email protected] ' )],
$ e->
getRecipients ());
93
92
}
0 commit comments