public function MailHandlerTest::getSendMailMessages in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 163 - Contains \Drupal\Tests\contact\Unit\MailHandlerTest.
Class
- MailHandlerTest
- @coversDefaultClass \Drupal\contact\MailHandler @group contact
Namespace
Drupal\Tests\contact\UnitCode
public function getSendMailMessages() {
$data = array();
$recipients = array(
'admin@drupal.org',
'user@drupal.org',
);
$default_result = array(
'module' => 'contact',
'key' => '',
'to' => implode(', ', $recipients),
'langcode' => 'en',
'params' => array(),
'from' => 'anonymous@drupal.org',
);
$results = array();
$message = $this
->getAnonymousMockMessage($recipients, '');
$sender = $this
->getMockSender();
$result = array(
'key' => 'page_mail',
'params' => array(
'contact_message' => $message,
'sender' => $sender,
'contact_form' => $message
->getContactForm(),
),
);
$results[] = $result + $default_result;
$data[] = array(
$message,
$sender,
$results,
);
$results = array();
$message = $this
->getAnonymousMockMessage($recipients, 'reply');
$sender = $this
->getMockSender();
$result = array(
'key' => 'page_mail',
'params' => array(
'contact_message' => $message,
'sender' => $sender,
'contact_form' => $message
->getContactForm(),
),
);
$results[] = $result + $default_result;
$result['key'] = 'page_autoreply';
$result['to'] = 'anonymous@drupal.org';
$result['from'] = NULL;
$results[] = $result + $default_result;
$data[] = array(
$message,
$sender,
$results,
);
$results = array();
$message = $this
->getAnonymousMockMessage($recipients, '', TRUE);
$sender = $this
->getMockSender();
$result = array(
'key' => 'page_mail',
'params' => array(
'contact_message' => $message,
'sender' => $sender,
'contact_form' => $message
->getContactForm(),
),
);
$results[] = $result + $default_result;
$result['key'] = 'page_copy';
$result['to'] = 'anonymous@drupal.org';
$results[] = $result + $default_result;
$data[] = array(
$message,
$sender,
$results,
);
$results = array();
$message = $this
->getAnonymousMockMessage($recipients, 'reply', TRUE);
$sender = $this
->getMockSender();
$result = array(
'key' => 'page_mail',
'params' => array(
'contact_message' => $message,
'sender' => $sender,
'contact_form' => $message
->getContactForm(),
),
);
$results[] = $result + $default_result;
$result['key'] = 'page_copy';
$result['to'] = 'anonymous@drupal.org';
$results[] = $result + $default_result;
$result['key'] = 'page_autoreply';
$result['from'] = NULL;
$results[] = $result + $default_result;
$data[] = array(
$message,
$sender,
$results,
);
//For authenticated user.
$results = array();
$message = $this
->getAuthenticatedMockMessage();
$sender = $this
->getMockSender(FALSE, 'user@drupal.org');
$result = array(
'module' => 'contact',
'key' => 'user_mail',
'to' => 'user2@drupal.org',
'langcode' => 'en',
'params' => array(
'contact_message' => $message,
'sender' => $sender,
'recipient' => $message
->getPersonalRecipient(),
),
'from' => 'user@drupal.org',
);
$results[] = $result;
$data[] = array(
$message,
$sender,
$results,
);
$results = array();
$message = $this
->getAuthenticatedMockMessage(TRUE);
$sender = $this
->getMockSender(FALSE, 'user@drupal.org');
$result = array(
'module' => 'contact',
'key' => 'user_mail',
'to' => 'user2@drupal.org',
'langcode' => 'en',
'params' => array(
'contact_message' => $message,
'sender' => $sender,
'recipient' => $message
->getPersonalRecipient(),
),
'from' => 'user@drupal.org',
);
$results[] = $result;
$result['key'] = 'user_copy';
$result['to'] = $result['from'];
$results[] = $result;
$data[] = array(
$message,
$sender,
$results,
);
return $data;
}