function OriginatorSubscriberTest::testCustomFrom
Ensure that the from address can be customized.
File
-
core/
modules/ mailer/ tests/ src/ Kernel/ OriginatorSubscriberTest.php, line 115
Class
- OriginatorSubscriberTest
- Tests default originator subscriber.
Namespace
Drupal\Tests\mailer\KernelCode
public function testCustomFrom() : void {
$expectedAddress = Address::create('custom-from@example.com');
$email = (new Email())->from('custom-from@example.com')
->subject('Notice soon as brother')
->text('House answer start behind. Around medical also its attorney before interesting step. Water piece on artist.');
$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);
$actualFrom = $originalEmail->getFrom();
$this->assertEquals([
$expectedAddress,
], $actualFrom);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.