function OriginatorSubscriberTest::testCustomEnvelope
Ensure that the envelope sender can be customized using a custom envelope.
File
-
core/
modules/ mailer/ tests/ src/ Kernel/ OriginatorSubscriberTest.php, line 299
Class
- OriginatorSubscriberTest
- Tests default originator subscriber.
Namespace
Drupal\Tests\mailer\KernelCode
public function testCustomEnvelope() : void {
$expectedAddress = Address::create('custom-envelope-sender@example.com');
$email = (new Email())->subject('Song cover finally phone rule.')
->text('Billion how choice at husband. Song share develop Mr everybody. Energy wall agent political.');
$transport = $this->container
->get(TransportInterface::class);
assert($transport instanceof TransportInterface);
$customEnvelope = Envelope::create($email);
$customEnvelope->setSender($expectedAddress);
$sentMessage = $transport->send($email->to('foobar@example.com'), $customEnvelope);
assert($sentMessage instanceof SentMessage);
$envelope = $sentMessage->getEnvelope();
$actualAddress = $envelope->getSender();
$this->assertEquals($expectedAddress, $actualAddress);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.