function MailHandlerTest::getSendMailMessages

Same name and namespace in other branches
  1. 9 core/modules/contact/tests/src/Unit/MailHandlerTest.php \Drupal\Tests\contact\Unit\MailHandlerTest::getSendMailMessages()
  2. 8.9.x core/modules/contact/tests/src/Unit/MailHandlerTest.php \Drupal\Tests\contact\Unit\MailHandlerTest::getSendMailMessages()
  3. 10 core/modules/contact/tests/src/Unit/MailHandlerTest.php \Drupal\Tests\contact\Unit\MailHandlerTest::getSendMailMessages()

Data provider for ::testSendMailMessages.

File

core/modules/contact/tests/src/Unit/MailHandlerTest.php, line 178

Class

MailHandlerTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21contact%21src%21MailHandler.php/class/MailHandler/11.x" title="Provides a class for handling assembly and dispatch of contact mail messages." class="local">\Drupal\contact\MailHandler</a> @group contact

Namespace

Drupal\Tests\contact\Unit

Code

public static function getSendMailMessages() {
    $default_result = [
        'module' => 'contact',
        'key' => 'page_mail',
        'to' => 'admin@drupal.org, user@drupal.org',
        'langcode' => 'en',
        'params' => [],
        'from' => 'anonymous@drupal.org',
    ];
    $autoreply_result = [
        'key' => 'page_autoreply',
        'to' => 'anonymous@drupal.org',
        'from' => NULL,
    ] + $default_result;
    $copy_result = [
        'key' => 'page_copy',
        'to' => 'anonymous@drupal.org',
    ] + $default_result;
    (yield 'anonymous, no auto reply, no copy sender' => [
        TRUE,
        FALSE,
        FALSE,
        [
            $default_result,
        ],
    ]);
    (yield 'anonymous, auto reply, no copy sender' => [
        TRUE,
        TRUE,
        FALSE,
        [
            $default_result,
            $autoreply_result,
        ],
    ]);
    (yield 'anonymous, no auto reply, copy sender' => [
        TRUE,
        FALSE,
        TRUE,
        [
            $default_result,
            $copy_result,
        ],
    ]);
    (yield 'anonymous, auto reply, copy sender' => [
        TRUE,
        TRUE,
        TRUE,
        [
            $default_result,
            $copy_result,
            $autoreply_result,
        ],
    ]);
    // For authenticated user.
    $default_result = [
        'module' => 'contact',
        'key' => 'user_mail',
        'to' => 'user2@drupal.org',
        'langcode' => 'en',
        'from' => 'user@drupal.org',
    ];
    $copy_result = [
        'key' => 'user_copy',
        'to' => 'user@drupal.org',
    ] + $default_result;
    (yield 'authenticated, no copy sender' => [
        FALSE,
        NULL,
        FALSE,
        [
            $default_result,
        ],
    ]);
    (yield 'authenticated, copy sender' => [
        FALSE,
        NULL,
        TRUE,
        [
            $default_result,
            $copy_result,
        ],
    ]);
}

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