function OriginatorSubscriberTest::testCustomMessageSender
Ensure that the message sender is set to the site mail with custom from.
File
-
core/
modules/ mailer/ tests/ src/ Kernel/ OriginatorSubscriberTest.php, line 206
Class
- OriginatorSubscriberTest
- Tests default originator subscriber.
Namespace
Drupal\Tests\mailer\KernelCode
public function testCustomMessageSender() : void {
$expectedAddress = Address::create('custom-message-sender@example.com');
$email = (new Email())->from('custom-from@example.com')
->sender('custom-message-sender@example.com')
->subject('Field return long bed after.')
->text('Machine energy a production. Whole same floor against major cup their. Much behind nor record rock production particular.');
$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.