function OriginatorSubscriberTest::testDefaultMessageSenderWithCustomFrom
Ensure that the message sender is set to the site mail with custom from.
File
-
core/
modules/ mailer/ tests/ src/ Kernel/ OriginatorSubscriberTest.php, line 183
Class
- OriginatorSubscriberTest
- Tests default originator subscriber.
Namespace
Drupal\Tests\mailer\KernelCode
public function testDefaultMessageSenderWithCustomFrom() : void {
$expectedAddress = Address::create('Example Site <site-mail@example.com>');
$email = (new Email())->from('custom-from@example.com')
->subject('Have heart cover analysis carry.')
->text('Billion how choice at husband. Song share develop Mr everybody.');
$transport = $this->container
->get(TransportInterface::class);
assert($transport instanceof TransportInterface);
$sentMessage = $transport->send($email->to('foobar@example.com'));
assert($sentMessage instanceof SentMessage);
$originalEmail = $sentMessage->getOriginalMessage();
assert($originalEmail instanceof Email);
$actualSender = $originalEmail->getSender();
$this->assertEquals($expectedAddress, $actualSender);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.