function SymfonyMailerTest::providerMail

Data provider for testMail().

File

core/tests/Drupal/Tests/Core/Mail/Plugin/Mail/SymfonyMailerTest.php, line 155

Class

SymfonyMailerTest
Tests Drupal\Core\Mail\Plugin\Mail\SymfonyMailer.

Namespace

Drupal\Tests\Core\Mail\Plugin\Mail

Code

public static function providerMail() : array {
  // Verify we use line endings consistent with the PHP mail() function, which
  // changed with PHP 8. See:
  // - https://www.drupal.org/node/3270647
  // - https://bugs.php.net/bug.php?id=81158
  $line_end = "\r\n";
  return [
    'defaults' => [
      [
        'from' => 'from@example.org',
        'reply-to' => 'from@example.org',
        'to' => 'to@example.org',
        'subject' => 'test subject',
      ],
      [
        'from' => '"Foo, Bar, and Baz" <from@example.org>',
        'reply-to' => 'from@example.org',
        'to' => 'to@example.org',
        'subject' => 'test subject',
      ],
    ],
    'line endings in subject' => [
      [
        'from' => 'from@example.org',
        'reply-to' => 'from@example.org',
        'to' => 'to@example.org',
        'subject' => "test\r\nsubject",
      ],
      [
        'from' => '"Foo, Bar, and Baz" <from@example.org>',
        'reply-to' => 'from@example.org',
        'to' => 'to@example.org',
        'subject' => "=?utf-8?Q?test?={$line_end} =?utf-8?Q?subject?=",
      ],
    ],
    'multiple comma-separated recipients' => [
      [
        'from' => 'from@example.org',
        'reply-to' => 'from@example.org',
        'to' => 'foo@example.org,bar@example.org',
        'subject' => 'test subject',
      ],
      [
        'from' => '"Foo, Bar, and Baz" <from@example.org>',
        'reply-to' => 'from@example.org',
        'to' => 'foo@example.org, bar@example.org',
        'subject' => 'test subject',
      ],
    ],
  ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.