You are here

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\Mail

Code

public function bodyDataProvider() {
  return [
    'with html' => [
      'message' => [
        'body' => [
          Markup::create('<p>Lorem ipsum &amp; dolor sit amet</p>'),
          Markup::create('<p>consetetur &lt; sadipscing elitr</p>'),
        ],
      ],
      'expected' => [
        "<p>Lorem ipsum &amp; dolor sit amet</p>",
        "<p>consetetur &lt; 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 &amp; dolor sit amet<br>\nconsetetur &lt; 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 &amp; World #@number</p>', [
            '@number' => 2,
          ]),
          Markup::create('<p>Hello &amp; <strong>World</strong></p>'),
        ],
      ],
      'expected' => [
        "<p>Hello &amp; World</p>",
        "<p>Hello &amp; &lt;strong&gt;World&lt;/strong&gt;</p>",
        "<p>Hello &amp; World #2</p>",
        "<p>Hello &amp; <strong>World</strong></p>",
      ],
      'expected_plain' => [
        "Hello & World",
        "Hello & <strong>World</strong>\n",
        "Hello & World #2\n",
        "Hello & WORLD",
      ],
    ],
  ];
}