@@ -70,7 +70,30 @@ public function testSendWithDefaultTransport()
70
70
$ this ->assertInstanceOf (Email::class, $ sentEmail );
71
71
$ this ->assertSame ($ to , $ sentEmail ->getTo ()[0 ]->getEncodedAddress ());
72
72
$ this ->assertSame ($ from , $ sentEmail ->getFrom ()[0 ]->getEncodedAddress ());
73
- $ this ->assertSame (sprintf ('New SMS on phone number: %s ' , $ phone ), $ sentEmail ->getSubject ());
73
+ $ this ->assertSame (\sprintf ('New SMS to phone number %s ' , $ phone ), $ sentEmail ->getSubject ());
74
+ $ this ->assertSame ($ subject , $ sentEmail ->getTextBody ());
75
+ $ this ->assertFalse ($ sentEmail ->getHeaders ()->has ('X-Transport ' ));
76
+ }
77
+
78
+ public function testSendWithFrom ()
79
+ {
80
+ $ transportName = null ;
81
+
82
+ $ message = new SmsMessage ($ phone = '0611223344 ' , $ subject = 'Hello! ' , $ fromPhone = '0655667788 ' );
83
+
84
+ $ mailer = new DummyMailer ();
85
+
86
+ $ transport = (new FakeSmsEmailTransport ($ mailer , $ to = 'recipient@email.net ' , $ from = 'sender@email.net ' ));
87
+ $ transport ->setHost ($ transportName );
88
+
89
+ $ transport ->send ($ message );
90
+
91
+ /** @var Email $sentEmail */
92
+ $ sentEmail = $ mailer ->getSentEmail ();
93
+ $ this ->assertInstanceOf (Email::class, $ sentEmail );
94
+ $ this ->assertSame ($ to , $ sentEmail ->getTo ()[0 ]->getEncodedAddress ());
95
+ $ this ->assertSame ($ from , $ sentEmail ->getFrom ()[0 ]->getEncodedAddress ());
96
+ $ this ->assertSame (\sprintf ('New SMS to phone number %s from %s ' , $ phone , $ fromPhone ), $ sentEmail ->getSubject ());
74
97
$ this ->assertSame ($ subject , $ sentEmail ->getTextBody ());
75
98
$ this ->assertFalse ($ sentEmail ->getHeaders ()->has ('X-Transport ' ));
76
99
}
@@ -93,7 +116,7 @@ public function testSendWithCustomTransport()
93
116
$ this ->assertInstanceOf (Email::class, $ sentEmail );
94
117
$ this ->assertSame ($ to , $ sentEmail ->getTo ()[0 ]->getEncodedAddress ());
95
118
$ this ->assertSame ($ from , $ sentEmail ->getFrom ()[0 ]->getEncodedAddress ());
96
- $ this ->assertSame (sprintf ('New SMS on phone number: %s ' , $ phone ), $ sentEmail ->getSubject ());
119
+ $ this ->assertSame (\ sprintf ('New SMS to phone number %s ' , $ phone ), $ sentEmail ->getSubject ());
97
120
$ this ->assertSame ($ subject , $ sentEmail ->getTextBody ());
98
121
$ this ->assertTrue ($ sentEmail ->getHeaders ()->has ('X-Transport ' ));
99
122
$ this ->assertSame ($ transportName , $ sentEmail ->getHeaders ()->get ('X-Transport ' )->getBody ());
0 commit comments