forked from symfony/symfony
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support SmsMessage with 'from' set
Fixes `Error Email does not comply with addr-spec of RFC 2822` See: symfony#58535
- Loading branch information
Showing
4 changed files
with
30 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,30 @@ public function testSendWithDefaultTransport() | |
$this->assertInstanceOf(Email::class, $sentEmail); | ||
$this->assertSame($to, $sentEmail->getTo()[0]->getEncodedAddress()); | ||
$this->assertSame($from, $sentEmail->getFrom()[0]->getEncodedAddress()); | ||
$this->assertSame(sprintf('New SMS on phone number: %s', $phone), $sentEmail->getSubject()); | ||
$this->assertSame(\sprintf('New SMS to phone number %s', $phone), $sentEmail->getSubject()); | ||
$this->assertSame($subject, $sentEmail->getTextBody()); | ||
$this->assertFalse($sentEmail->getHeaders()->has('X-Transport')); | ||
} | ||
|
||
public function testSendWithFrom() | ||
{ | ||
$transportName = null; | ||
|
||
$message = new SmsMessage($phone = '0611223344', $subject = 'Hello!', $fromPhone = '0655667788'); | ||
|
||
$mailer = new DummyMailer(); | ||
|
||
$transport = (new FakeSmsEmailTransport($mailer, $to = '[email protected]', $from = '[email protected]')); | ||
$transport->setHost($transportName); | ||
|
||
$transport->send($message); | ||
|
||
/** @var Email $sentEmail */ | ||
$sentEmail = $mailer->getSentEmail(); | ||
$this->assertInstanceOf(Email::class, $sentEmail); | ||
$this->assertSame($to, $sentEmail->getTo()[0]->getEncodedAddress()); | ||
$this->assertSame($from, $sentEmail->getFrom()[0]->getEncodedAddress()); | ||
$this->assertSame(\sprintf('New SMS to phone number %s from %s', $phone, $fromPhone), $sentEmail->getSubject()); | ||
$this->assertSame($subject, $sentEmail->getTextBody()); | ||
$this->assertFalse($sentEmail->getHeaders()->has('X-Transport')); | ||
} | ||
|
@@ -93,7 +116,7 @@ public function testSendWithCustomTransport() | |
$this->assertInstanceOf(Email::class, $sentEmail); | ||
$this->assertSame($to, $sentEmail->getTo()[0]->getEncodedAddress()); | ||
$this->assertSame($from, $sentEmail->getFrom()[0]->getEncodedAddress()); | ||
$this->assertSame(sprintf('New SMS on phone number: %s', $phone), $sentEmail->getSubject()); | ||
$this->assertSame(\sprintf('New SMS to phone number %s', $phone), $sentEmail->getSubject()); | ||
$this->assertSame($subject, $sentEmail->getTextBody()); | ||
$this->assertTrue($sentEmail->getHeaders()->has('X-Transport')); | ||
$this->assertSame($transportName, $sentEmail->getHeaders()->get('X-Transport')->getBody()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters