16
16
use Symfony \Component \Mime \Address ;
17
17
use Symfony \Component \Mime \Header \Headers ;
18
18
use Symfony \Component \Mime \Message ;
19
- use Symfony \Component \Mime \NamedAddress ;
20
19
21
20
class SmtpEnvelopeTest extends TestCase
22
21
{
@@ -28,13 +27,13 @@ public function testConstructorWithAddressSender()
28
27
29
28
public function testConstructorWithNamedAddressSender ()
30
29
{
31
- $ e =
new SmtpEnvelope (
new NamedAddress (
'[email protected] ' ,
'Fabien ' ), [
new Address (
'[email protected] ' )]);
30
+ $ e =
new SmtpEnvelope (
new Address (
'[email protected] ' ,
'Fabien ' ), [
new Address (
'[email protected] ' )]);
32
31
$ this ->
assertEquals (
new Address (
'[email protected] ' ),
$ e->
getSender ());
33
32
}
34
33
35
34
public function testConstructorWithAddressRecipients ()
36
35
{
37
- $ e =
new SmtpEnvelope (
new Address (
'[email protected] ' ), [
new Address (
'[email protected] ' ),
new NamedAddress (
'[email protected] ' ,
'Lucas ' )]);
36
+ $ e =
new SmtpEnvelope (
new Address (
'[email protected] ' ), [
new Address (
'[email protected] ' ),
new Address (
'[email protected] ' ,
'Lucas ' )]);
38
37
$ this ->
assertEquals ([
new Address (
'[email protected] ' ),
new Address (
'[email protected] ' )],
$ e->
getRecipients ());
39
38
}
40
39
@@ -53,19 +52,19 @@ public function testConstructorWithWrongRecipients()
53
52
public function testSenderFromHeaders ()
54
53
{
55
54
$ headers = new Headers ();
56
- $ headers->
addPathHeader (
'Return-Path ' ,
new NamedAddress (
'[email protected] ' ,
'return ' ));
55
+ $ headers->
addPathHeader (
'Return-Path ' ,
new Address (
'[email protected] ' ,
'return ' ));
57
56
$ headers->
addMailboxListHeader (
'To ' , [
'[email protected] ' ]);
58
57
$ e = SmtpEnvelope::create (new Message ($ headers ));
59
58
$ this ->
assertEquals (
'[email protected] ' ,
$ e->
getSender ()->
getAddress ());
60
59
61
60
$ headers = new Headers ();
62
- $ headers->
addMailboxHeader (
'Sender ' ,
new NamedAddress (
'[email protected] ' ,
'sender ' ));
61
+ $ headers->
addMailboxHeader (
'Sender ' ,
new Address (
'[email protected] ' ,
'sender ' ));
63
62
$ headers->
addMailboxListHeader (
'To ' , [
'[email protected] ' ]);
64
63
$ e = SmtpEnvelope::create (new Message ($ headers ));
65
64
$ this ->
assertEquals (
'[email protected] ' ,
$ e->
getSender ()->
getAddress ());
66
65
67
66
$ headers = new Headers ();
68
- $ headers->
addMailboxListHeader (
'From ' , [
new NamedAddress (
'[email protected] ' ,
'from ' ),
'[email protected] ' ]);
67
+ $ headers->
addMailboxListHeader (
'From ' , [
new Address (
'[email protected] ' ,
'from ' ),
'[email protected] ' ]);
69
68
$ headers->
addMailboxListHeader (
'To ' , [
'[email protected] ' ]);
70
69
$ e = SmtpEnvelope::create (new Message ($ headers ));
71
70
$ this ->
assertEquals (
'[email protected] ' ,
$ e->
getSender ()->
getAddress ());
@@ -76,17 +75,17 @@ public function testSenderFromHeadersWithoutFrom()
76
75
$ headers = new Headers ();
77
76
$ headers->
addMailboxListHeader (
'To ' , [
'[email protected] ' ]);
78
77
$ e = SmtpEnvelope::create ($ message = new Message ($ headers ));
79
- $ message->
getHeaders ()->
addMailboxListHeader (
'From ' , [
new NamedAddress (
'[email protected] ' ,
'from ' )]);
78
+ $ message->
getHeaders ()->
addMailboxListHeader (
'From ' , [
new Address (
'[email protected] ' ,
'from ' )]);
80
79
$ this ->
assertEquals (
'[email protected] ' ,
$ e->
getSender ()->
getAddress ());
81
80
}
82
81
83
82
public function testRecipientsFromHeaders ()
84
83
{
85
84
$ headers = new Headers ();
86
85
$ headers->
addPathHeader (
'Return-Path ' ,
'[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 ' )]);
86
+ $ headers->
addMailboxListHeader (
'To ' , [
new Address (
'[email protected] ' ,
'to ' )]);
87
+ $ headers->
addMailboxListHeader (
'Cc ' , [
new Address (
'[email protected] ' ,
'cc ' )]);
88
+ $ headers->
addMailboxListHeader (
'Bcc ' , [
new Address (
'[email protected] ' ,
'bcc ' )]);
90
89
$ e = SmtpEnvelope::create (new Message ($ headers ));
91
90
$ this ->
assertEquals ([
new Address (
'[email protected] ' ),
new Address (
'[email protected] ' ),
new Address (
'[email protected] ' )],
$ e->
getRecipients ());
92
91
}
0 commit comments