CodeExplorer addAttachmentUrl example
->
setMailAttachmentsConfig($additionalData['attachmentsConfig'
] ?? null
);
foreach ($contents as $contentType =>
$data) { if ($contentType === 'text/html'
) { $mail->
html($data);
} else { $mail->
text($data);
} } foreach ($attachments as $url) { $mail->
addAttachmentUrl($url);
} if (isset($binAttachments)) { foreach ($binAttachments as $binAttachment) { $mail->
attach( $binAttachment['content'
],
$binAttachment['fileName'
],
$binAttachment['mimeType'
] );
} } $envelope =
$this->
createMock(Envelope::
class);
$this->decorated->
expects(static::
once())->
method('send'
)->
with($mail,
$envelope);
$this->decorator->
send($mail,
$envelope);
} public function testMailerTransportDecoratorWithUrlAttachments(): void
{ $mail =
new Mail();
$envelope =
$this->
createMock(Envelope::
class);
$mail->
addAttachmentUrl('foo'
);
$mail->
addAttachmentUrl('bar'
);
$this->filesystem->
write('foo', 'foo'
);
$this->filesystem->
write('bar', 'bar'
);
$this->decorated->
expects(static::
once())->
method('send'
)->
with($mail,
$envelope);
$this->decorator->
send($mail,
$envelope);
$attachments =
$mail->
getAttachments();
static::
assertCount(2,
$attachments);