public function FormatTest::bodyDataProvider in Swift Mailer 8.2
Data provider of body data.
File
- tests/
src/ Kernel/ Plugin/ Mail/ FormatTest.php, line 92
Class
- FormatTest
- @coversDefaultClass \Drupal\swiftmailer\Plugin\Mail\SwiftMailer @group swiftmailer
Namespace
Drupal\Tests\swiftmailer\Kernel\Plugin\MailCode
public function bodyDataProvider() {
return [
'with html' => [
'message' => [
'body' => [
Markup::create('<p>Lorem ipsum & dolor sit amet</p>'),
Markup::create('<p>consetetur < sadipscing elitr</p>'),
],
],
'expected' => [
"<p>Lorem ipsum & dolor sit amet</p>",
"<p>consetetur < sadipscing elitr</p>",
],
'expected_plain' => [
"Lorem ipsum & dolor sit amet\n",
"consetetur < sadipscing elitr",
],
],
'no html' => [
'message' => [
'body' => [
"Lorem ipsum & dolor sit amet\nconsetetur < sadipscing elitr",
"URL is http://example.com",
],
],
'expected' => [
"<p>Lorem ipsum & dolor sit amet<br>\nconsetetur < sadipscing elitr</p>",
'<p>URL is <a href="http://example.com">http://example.com</a></p>',
],
'expected_plain' => [
"Lorem ipsum & dolor sit amet\nconsetetur < sadipscing elitr",
"URL is http://example.com",
],
],
'mixed' => [
'message' => [
'body' => [
'Hello & World',
// Next, the content of the message contains strings that look like
// markup. For example it could be a website lecturer explaining
// to students about the <strong> tag.
'Hello & <strong>World</strong>',
new FormattableMarkup('<p>Hello & World #@number</p>', [
'@number' => 2,
]),
Markup::create('<p>Hello & <strong>World</strong></p>'),
],
],
'expected' => [
"<p>Hello & World</p>",
"<p>Hello & <strong>World</strong></p>",
"<p>Hello & World #2</p>",
"<p>Hello & <strong>World</strong></p>",
],
'expected_plain' => [
"Hello & World",
"Hello & <strong>World</strong>\n",
"Hello & World #2\n",
"Hello & WORLD",
],
],
];
}