use Symfony\Component\Mime\Header\UnstructuredHeader;
use Symfony\Component\Mime\Message;
class MessageListenerTest extends TestCase
{ /**
* @dataProvider provideHeaders
*/
public function testHeaders(Headers
$initialHeaders, Headers
$defaultHeaders, Headers
$expectedHeaders, array
$rules = MessageListener::DEFAULT_RULES
) { $message =
new Message($initialHeaders);
$listener =
new MessageListener($defaultHeaders, null,
$rules);
$event =
new MessageEvent($message,
new Envelope(new Address('sender@example.com'
),
[new Address('recipient@example.com'
)]), 'smtp'
);
$listener->
onMessage($event);
$this->
assertEquals($expectedHeaders,
$event->
getMessage()->
getHeaders());
} public static function provideHeaders(): iterable
{ $initialHeaders =
new Headers();
$defaultHeaders =
(new Headers()) ->
add(new MailboxListHeader('from',
[new Address('from-default@example.com'
)])) ;