Skip to content
Snippets Groups Projects
Commit 7393350f authored by MUNAVIJAYALAKSHMI P's avatar MUNAVIJAYALAKSHMI P Committed by Jason Flatt
Browse files

Issue #2880236 by Munavijayalakshmi, dhruveshdtripathi: Convert module to use...

Issue #2880236 by Munavijayalakshmi, dhruveshdtripathi: Convert module to use short array syntax (new coding standard)
parent 11329b48
No related branches found
No related tags found
No related merge requests found
......@@ -85,7 +85,7 @@ function mimemail_phpmailer_send($message) {
return $mail->SmtpSend($header, $message['body']);
}
catch (phpmailerException $e) {
drupal_set_message(t('Sending of at least one e-mail failed. The error returned was:<br />@error.', array('@error' => $e->getMessage())), 'error');
drupal_set_message(t('Sending of at least one e-mail failed. The error returned was:<br />@error.', ['@error' => $e->getMessage()]), 'error');
\Drupal::logger('phpmailer')->error($e->getMessage());
return FALSE;
}
......
......@@ -9,32 +9,32 @@
* Implementation of hook_requirements().
*/
function phpmailer_requirements($phase) {
$requirements = array();
$requirements = [];
if (class_exists('PHPMailer')) {
$mail = new PHPMailer();
}
if (empty($mail)) {
$requirements['phpmailer'] = array(
$requirements['phpmailer'] = [
'title' => (string) t('PHPMailer library'),
'value' => (string) t('Missing'),
'severity' => REQUIREMENT_ERROR,
'description' => (string) t("Please install the PHPMailer library by executing 'composer update' in your site's root directory."),
);
];
}
else {
$required_version = '5.2.21';
$installed_version = $mail->Version;
$requirements['phpmailer'] = array(
$requirements['phpmailer'] = [
'title' => (string) t('PHPMailer library'),
'value' => $installed_version,
);
];
if (!version_compare($installed_version, $required_version, '>=')) {
$requirements['phpmailer']['severity'] = REQUIREMENT_ERROR;
$requirements['phpmailer']['description'] = (string) t("PHPMailer library @version or higher is required. Please install a newer version by executing 'composer update' in your site's root directory.", array(
$requirements['phpmailer']['description'] = (string) t("PHPMailer library @version or higher is required. Please install a newer version by executing 'composer update' in your site's root directory.", [
'@version' => $required_version,
));
]);
}
else {
$requirements['phpmailer']['severity'] = REQUIREMENT_OK;
......@@ -60,7 +60,7 @@ function phpmailer_install() {
// /**
// * @todo This part needs to be figured out.
// */
// mailsystem_set(array('phpmailer' => 'DrupalPHPMailer'));
// mailsystem_set(['phpmailer' => 'DrupalPHPMailer']);
// }
}
......@@ -71,13 +71,13 @@ function phpmailer_uninstall() {
/**
* @todo This part needs to be figured out.
*/
// $mail_system = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
// $mail_system = variable_get('mail_system', ['default-system' => 'DefaultMailSystem']);
// $mail_system['default-system'] = 'DefaultMailSystem';
// variable_set('mail_system', $mail_system);
if (phpmailer_active()) {
// Remove PHPMailer from all mail keys it is configured for.
// $mail_system = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
// $mail_system = variable_get('mail_system', ['default-system' => 'DefaultMailSystem']);
// foreach ($mail_system as $key => $class) {
// if ($class == 'DrupalPHPMailer') {
// if ($key != 'default-system') {
......@@ -107,6 +107,6 @@ function phpmailer_uninstall() {
if (\Drupal::moduleHandler()->moduleExists('mailsystem')) {
// This function does not exist in the D8 port of Mail System.
// mailsystem_clear(array('phpmailer' => 'DrupalPHPMailer'));
// mailsystem_clear(['phpmailer' => 'DrupalPHPMailer']);
}
}
......@@ -23,18 +23,18 @@ function phpmailer_form_mimemail_admin_settings_alter(&$form, &$form_state) {
$mimemail_alter['#disabled'] = TRUE;
$mimemail_alter['#default_value'] = 0;
$phpmailer_settings = \Drupal::l(t('PHPMailer settings page'), Url::fromRoute('phpmailer.settings'));
$mimemail_alter['#description'] = t('PHPMailer has been set to deliver all site messages. To let Mime Mail apply styles and formatting to system e-mails but still use PHPMailer for mail transport, uncheck <em>Use PHPMailer to send e-mails</em> first on the @url. Then activate this setting and choose PHPMailer from the list of e-mail engines below.', array('@url' => $phpmailer_settings));
$mimemail_alter['#description'] = t('PHPMailer has been set to deliver all site messages. To let Mime Mail apply styles and formatting to system e-mails but still use PHPMailer for mail transport, uncheck <em>Use PHPMailer to send e-mails</em> first on the @url. Then activate this setting and choose PHPMailer from the list of e-mail engines below.', ['@url' => $phpmailer_settings]);
}
// @todo Move to MimeMail project.
/**
* @todo This needs to be figured out.
*/
$phpmailer_preview = \Drupal::l(t('preview of a styled e-mail'), Url::fromRoute('phpmailer/preview'));
$form['preview'] = array(
$form['preview'] = [
'#type' => 'item',
'#title' => t('Preview'),
'#value' => t('See a @url using the current message template (<code>mimemail-message.tpl.php</code>).', array('@url' => $phpmailer_preview)),
);
'#value' => t('See a @url using the current message template (<code>mimemail-message.tpl.php</code>).', ['@url' => $phpmailer_preview]),
];
$form['buttons']['#weight'] = 10;
}
......@@ -43,21 +43,21 @@ function phpmailer_form_mimemail_admin_settings_alter(&$form, &$form_state) {
*
* This is for the Mime Mail module.
*/
function phpmailer_mailengine($op, $message = array()) {
function phpmailer_mailengine($op, $message = []) {
if (!class_exists('PHPMailer')) {
return;
}
switch ($op) {
case 'list':
return array(
return [
'name' => t('PHPMailer'),
'description' => t('Mailing engine using the PHPMailer library.'),
);
];
case 'settings':
$phpmailer_settings = \Drupal::l(t('PHPMailer settings page'), Url::fromRoute('phpmailer.settings'));
$form['info']['#markup'] = t('To configure your mail server settings, visit the @url.', array('@url' => $phpmailer_settings));
$form['info']['#markup'] = t('To configure your mail server settings, visit the @url.', ['@url' => $phpmailer_settings]);
return $form;
case 'multiple':
......@@ -105,7 +105,7 @@ function phpmailer_active() {
* @see http://tools.ietf.org/html/rfc5322#section-3.4
*/
function phpmailer_parse_address($string) {
$parsed = array();
$parsed = [];
// The display name may contain commas (3.4). Extract all quoted strings
// (3.2.4) to a stack and replace them with a placeholder to prevent
......@@ -128,10 +128,10 @@ function phpmailer_parse_address($string) {
// Check if it's a name-addr or a plain address (3.4).
if (preg_match($adr_rx, $email, $matches)) {
// PHPMailer expects an unencoded display name.
$parsed[] = array('mail' => $matches['address'], 'name' => Unicode::mimeHeaderDecode(stripslashes($matches['name'])));
$parsed[] = ['mail' => $matches['address'], 'name' => Unicode::mimeHeaderDecode(stripslashes($matches['name']))];
}
else {
$parsed[] = array('mail' => trim($email, '<>'), 'name' => '');
$parsed[] = ['mail' => trim($email, '<>'), 'name' => ''];
}
}
return $parsed;
......@@ -142,11 +142,11 @@ function phpmailer_parse_address($string) {
*/
function _phpmailer_stack($matches = NULL) {
$string = $matches[0];
static $stack = array();
static $stack = [];
if ($string == "\x01") {
// Unescape quoted characters (3.2.4) to prevent double escaping.
return str_replace(array('\"', '\\\\'), array('"', '\\'), array_shift($stack));
return str_replace(['\"', '\\\\'], ['"', '\\'], array_shift($stack));
}
// Remove surrounding quotes and push on stack.
array_push($stack, substr($string, 1, -1));
......
......@@ -61,7 +61,7 @@ class PHPMailerMailPreviewController {
$subject = _user_mail_text('register_no_approval_required_subject', $lang_code, $variables);
$body = _user_mail_text('register_no_approval_required_body', $lang_code, $variables);
$sender = NULL;
$headers = array();
$headers = [];
// Convert non-html messages.
// @see drupal_mail_wrapper()
......
......@@ -72,12 +72,12 @@ class SettingsForm extends ConfigFormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('phpmailer.settings');
$form['smtp_on'] = array(
$form['smtp_on'] = [
'#type' => 'checkbox',
'#title' => t('Activate PHPMailer to send e-mails'),
'#default_value' => $config->get('smtp_on'),
'#description' => t('When enabled, PHPMailer will be used to deliver all site e-mails.'),
);
];
/**
* @todo This part needs to be figured out.
*/
......@@ -86,27 +86,27 @@ class SettingsForm extends ConfigFormBase {
// if (\Drupal::moduleHandler()->moduleExists('mimemail') && variable_get('mimemail_alter', 0)) {
// $form['smtp_on']['#disabled'] = TRUE;
// $form['smtp_on']['#default_value'] = 0;
// $form['smtp_on']['#description'] = t('MimeMail has been detected. To enable PHPMailer for mail transport, go to the <a href="@url">MimeMail settings page</a> and select PHPMailer from the available e-mail engines.', array('@url' => url('admin/config/system/mimemail')));
// $form['smtp_on']['#description'] = t('MimeMail has been detected. To enable PHPMailer for mail transport, go to the <a href="@url">MimeMail settings page</a> and select PHPMailer from the available e-mail engines.', ['@url' => url('admin/config/system/mimemail')]);
// }
// elseif (!$config->get('smtp_on') && empty($form_state['input'])) {
if (!$config->get('smtp_on') && empty($form_state->input)) {
drupal_set_message(t('PHPMailer is currently disabled.'), 'warning');
}
$form['server']['smtp_host'] = array(
$form['server']['smtp_host'] = [
'#type' => 'textfield',
'#title' => t('Primary SMTP server'),
'#default_value' => $config->get('smtp_host'),
'#description' => t('The host name or IP address of your primary SMTP server. Use %gmail-smtp for Google Mail.', array('%gmail-smtp' => 'smtp.gmail.com')),
'#description' => t('The host name or IP address of your primary SMTP server. Use %gmail-smtp for Google Mail.', ['%gmail-smtp' => 'smtp.gmail.com']),
'#required' => TRUE,
);
$form['server']['smtp_hostbackup'] = array(
];
$form['server']['smtp_hostbackup'] = [
'#type' => 'textfield',
'#title' => t('Backup SMTP server'),
'#default_value' => $config->get('smtp_hostbackup'),
'#description' => t('Optional host name or IP address of a backup server, if the primary server fails. You may override the default port below by appending it to the host name separated by a colon. Example: %hostname', array('%hostname' => 'localhost:465')),
);
$form['server']['smtp_port'] = array(
'#description' => t('Optional host name or IP address of a backup server, if the primary server fails. You may override the default port below by appending it to the host name separated by a colon. Example: %hostname', ['%hostname' => 'localhost:465']),
];
$form['server']['smtp_port'] = [
'#type' => 'textfield',
'#title' => t('SMTP port'),
'#size' => 5,
......@@ -114,14 +114,14 @@ class SettingsForm extends ConfigFormBase {
'#default_value' => $config->get('smtp_port'),
'#description' => t('The standard SMTP port is 25. Secure connections (including Google Mail), typically use 465.'),
'#required' => TRUE,
);
$form['server']['smtp_protocol'] = array(
];
$form['server']['smtp_protocol'] = [
'#type' => 'select',
'#title' => t('Use secure protocol'),
'#default_value' => $config->get('smtp_protocol'),
'#options' => array('' => t('No'), 'ssl' => t('SSL'), 'tls' => t('TLS')),
'#options' => ['' => t('No'), 'ssl' => t('SSL'), 'tls' => t('TLS')],
'#description' => t('Whether to use an encrypted connection to communicate with the SMTP server. Google Mail requires SSL.'),
);
];
if (!function_exists('openssl_open')) {
$form['server']['smtp_protocol']['#default_value'] = '';
$form['server']['smtp_protocol']['#disabled'] = TRUE;
......@@ -129,124 +129,124 @@ class SettingsForm extends ConfigFormBase {
$config->set('smtp_protocol', '')->save();
}
$form['auth'] = array(
$form['auth'] = [
'#type' => 'details',
'#title' => t('SMTP authentication'),
'#description' => t('Leave both fields empty, if your SMTP server does not require authentication.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['auth']['smtp_username'] = array(
];
$form['auth']['smtp_username'] = [
'#type' => 'textfield',
'#title' => t('Username'),
'#default_value' => $config->get('smtp_username'),
'#description' => t('For Google Mail, enter your username, including "@gmail.com".'),
);
];
if (!$config->get('smtp_hide_password')) {
$form['auth']['smtp_password'] = array(
$form['auth']['smtp_password'] = [
'#type' => 'textfield',
'#title' => t('Password'),
'#default_value' => $config->get('smtp_password'),
);
$form['auth']['smtp_hide_password'] = array(
];
$form['auth']['smtp_hide_password'] = [
'#type' => 'checkbox',
'#title' => t('Hide password'),
'#default_value' => 0,
'#description' => t("Check this option to permanently hide the plaintext password from peeking eyes. You may still change the password afterwards, but it won't be displayed anymore."),
);
];
}
else {
$have_password = ($config->get('smtp_password') != '');
$form['auth']['smtp_password'] = array(
$form['auth']['smtp_password'] = [
'#type' => 'password',
'#title' => $have_password ? t('Change password') : t('Password'),
'#description' => $have_password ? t('Leave empty, if you do not intend to change the current password.') : '',
);
];
}
$form['advanced'] = array(
$form['advanced'] = [
'#type' => 'details',
'#title' => t('Advanced SMTP settings'),
);
$form['advanced']['smtp_fromname'] = array(
];
$form['advanced']['smtp_fromname'] = [
'#type' => 'textfield',
'#title' => t('"From" name'),
'#default_value' => $config->get('smtp_fromname'),
'#description' => t('Enter a name that should appear as the sender for all messages. If left blank the site name will be used instead: %sitename.', array('%sitename' => $config->get('site_name'))),
);
$form['advanced']['smtp_always_replyto'] = array(
'#description' => t('Enter a name that should appear as the sender for all messages. If left blank the site name will be used instead: %sitename.', ['%sitename' => $config->get('site_name')]),
];
$form['advanced']['smtp_always_replyto'] = [
'#type' => 'checkbox',
'#title' => t('Always set "Reply-To" address'),
'#default_value' => $config->get('smtp_always_replyto'),
'#description' => t('Enables setting the "Reply-To" address to the original sender of the message, if unset. This is required when using Google Mail, which would otherwise overwrite the original sender.'),
);
$form['advanced']['smtp_keepalive'] = array(
];
$form['advanced']['smtp_keepalive'] = [
'#type' => 'checkbox',
'#title' => t('Keep connection alive'),
'#default_value' => $config->get('smtp_keepalive'),
'#description' => t('Whether to reuse an existing connection during a request. Improves performance when sending a lot of e-mails at once.'),
);
$form['advanced']['smtp_debug'] = array(
];
$form['advanced']['smtp_debug'] = [
'#type' => 'select',
'#title' => t('Debug level'),
'#default_value' => $config->get('smtp_debug'),
'#options' => array(0 => t('Disabled'), 1 => t('Errors only'), 2 => t('Server responses'), 4 => t('Full communication')),
'#options' => [0 => t('Disabled'), 1 => t('Errors only'), 2 => t('Server responses'), 4 => t('Full communication')],
'#description' => t("Debug the communication with the SMTP server. You normally shouldn't enable this unless you're trying to debug e-mail sending problems."),
);
$form['advanced']['smtp_debug_log'] = array(
];
$form['advanced']['smtp_debug_log'] = [
'#type' => 'checkbox',
'#title' => t("Record debugging output in Drupal's log"),
'#default_value' => $config->get('smtp_debug_log'),
'#description' => t("If this is checked, the debugging out put that is produced will also be recorded in Drupal's database log."),
'#states' => array(
'visible' => array(
':input[name=smtp_debug]' => array('!value' => 0),
),
),
);
'#states' => [
'visible' => [
':input[name=smtp_debug]' => ['!value' => 0],
],
],
];
$form['advanced']['ssl_settings'] = array(
$form['advanced']['ssl_settings'] = [
'#type' => 'fieldset',
'#title' => t('Advanced SSL settings'),
'#description' => t('If you are attempting to connect to a broken or malconfigured secure mail server, you can try toggling one or more of these options. <strong>If changing any of these options allows connection to the server, you should consider either fixing the SSL certifcate, or using a different SMTP server, as the connection may be insecure.</strong>'),
);
];
$ssl_verify_peer = $config->get('smtp_ssl_verify_peer');
$form['advanced']['ssl_settings']['smtp_ssl_verify_peer'] = array(
$form['advanced']['ssl_settings']['smtp_ssl_verify_peer'] = [
'#type' => 'checkbox',
'#title' => t('Verfy peer'),
'#default_value' => isset($ssl_verify_peer) ? $ssl_verify_peer : 1,
'#description' => t('If this is checked, it will require verification of the SSL certificate being used on the mail server.'),
);
];
$ssl_verify_peer_name = $config->get('smtp_ssl_verify_peer_name');
$form['advanced']['ssl_settings']['smtp_ssl_verify_peer_name'] = array(
$form['advanced']['ssl_settings']['smtp_ssl_verify_peer_name'] = [
'#type' => 'checkbox',
'#title' => t('Verfy peer name'),
'#default_value' => isset($ssl_verify_peer_name) ? $ssl_verify_peer_name : 1,
'#description' => t("If this is checked, it will require verification of the mail server's name in the SSL certificate."),
);
];
$ssl_allow_self_signed = $config->get('smtp_ssl_allow_self_signed');
$form['advanced']['ssl_settings']['smtp_ssl_allow_self_signed'] = array(
$form['advanced']['ssl_settings']['smtp_ssl_allow_self_signed'] = [
'#type' => 'checkbox',
'#title' => t('Allow self signed'),
'#default_value' => isset($ssl_allow_self_signed) ? $ssl_allow_self_signed : 0,
'#description' => t('If this is checked, it will allow conecting to a mail server with a self-signed SSL certificate. (This requires "Verfy peer" to be enabled.)'),
'#states' => array(
'enabled' => array(
':input[name="ssl_verify_peer"]' => array('checked' => TRUE),
),
),
);
'#states' => [
'enabled' => [
':input[name="ssl_verify_peer"]' => ['checked' => TRUE],
],
],
];
$form['test'] = array(
$form['test'] = [
'#type' => 'details',
'#title' => t('Test configuration'),
);
$form['test']['phpmailer_test'] = array(
];
$form['test']['phpmailer_test'] = [
'#type' => 'textfield',
'#title' => t('Recipient'),
'#default_value' => '',
'#description' => t('Type in an address to have a test e-mail sent there.'),
);
];
return parent::buildForm($form, $form_state);
}
......@@ -343,17 +343,17 @@ class SettingsForm extends ConfigFormBase {
// Otherwise, prepare and send the test mail manually.
else {
// Prepare the message without sending.
$message = \Drupal::service('plugin.manager.mail')->mail('phpmailer', 'test', $values['phpmailer_test'], $langcode, array(), NULL, FALSE);
$message = \Drupal::service('plugin.manager.mail')->mail('phpmailer', 'test', $values['phpmailer_test'], $langcode, [], NULL, FALSE);
// Send the message.
module_load_include('inc', 'phpmailer', 'includes/phpmailer.drupal');
$ret_val = phpmailer_send($message);
}
$watchdog_url = Url::fromRoute('dblog.overview');
$watchdog_url = \Drupal::l(t('Check the logs'), $watchdog_url);
drupal_set_message(t('A test e-mail has been sent to %email. @watchdog-url for any error messages.', array(
drupal_set_message(t('A test e-mail has been sent to %email. @watchdog-url for any error messages.', [
'%email' => $values['phpmailer_test'],
'@watchdog-url' => $watchdog_url,
)));
]));
}
parent::submitForm($form, $form_state);
......
......@@ -127,7 +127,7 @@ class DrupalPHPMailer extends PHPMailer implements MailInterface {
if ($this->drupalDebug && ($this->drupalDebugOutput = ob_get_contents())) {
drupal_set_message($this->drupalDebugOutput);
if (\Drupal::config('phpmailer.settings')->get('smtp_debug_log', 0)) {
\Drupal::logger('phpmailer')->debug('Output of communication with SMTP server:<br /><pre>{output}</pre>', array('output' => print_r($this->drupalDebugOutput, TRUE)));
\Drupal::logger('phpmailer')->debug('Output of communication with SMTP server:<br /><pre>{output}</pre>', ['output' => print_r($this->drupalDebugOutput, TRUE)]);
}
}
ob_end_clean();
......@@ -198,7 +198,7 @@ class DrupalPHPMailer extends PHPMailer implements MailInterface {
parent::SetLanguage('en');
// Overload with Drupal translations.
$this->language = array(
$this->language = [
'authenticate' => t('SMTP error: Could not authenticate.'),
'connect_host' => t('SMTP error: Could not connect to host.'),
'data_not_accepted' => t('SMTP error: Data not accepted.'),
......@@ -218,7 +218,7 @@ class DrupalPHPMailer extends PHPMailer implements MailInterface {
'invalid_address' => t('Invalid address'),
'provide_address' => t('You must provide at least one recipient e-mail address.'),
'recipients_failed' => t('The following recipients failed: '),
) + $this->language;
] + $this->language;
return TRUE;
}
......@@ -339,13 +339,13 @@ class DrupalPHPMailer extends PHPMailer implements MailInterface {
}
// Set additional properties.
$properties = array(
$properties = [
'X-Priority' => 'Priority',
'Content-Transfer-Encoding' => 'Encoding',
'Sender' => 'Sender',
'Message-ID' => 'MessageID',
'Return-Path' => 'ReturnPath',
);
];
foreach ($properties as $source => $property) {
if (isset($message['headers'][$source])) {
$this->$property = $message['headers'][$source];
......@@ -380,16 +380,16 @@ class DrupalPHPMailer extends PHPMailer implements MailInterface {
$output = $e->getMessage();
// Attempt to delimit summary from full message.
$output .= " \n";
$arguments = array();
$arguments = [];
// Append SMTP communication output.
if ($this->drupalDebugOutput) {
// PHPMailer debug output contains HTML linebreaks. PRE is more readable.
$this->drupalDebugOutput = str_replace('<br />', '', $this->drupalDebugOutput);
$output .= '<p><strong>Server response:</strong></p>';
$output .= "<pre>\n@smtp_output\n</pre>";
$arguments += array(
$arguments += [
'@smtp_output' => $this->drupalDebugOutput,
);
];
}
// We need to log the message in order to be able to debug why the server
// responded with an error. The mail body may contain passwords and other
......@@ -402,23 +402,23 @@ class DrupalPHPMailer extends PHPMailer implements MailInterface {
// Subject.
$output .= "<p><strong>Subject:</strong> \n@subject\n</p>";
$arguments += array(
$arguments += [
'@subject' => $message['subject'],
);
];
unset($message['subject']);
// Body.
$output .= '<p><strong>Body:</strong></p>';
$output .= "<pre>\n@body\n</pre>";
$arguments += array(
$arguments += [
'@body' => $message['body'],
);
];
unset($message['body']);
// Rest of $message.
$output .= '<p><strong>Message:</strong></p>';
$output .= "<pre>\n@message\n</pre>";
$arguments += array(
$arguments += [
'@message' => var_export($message, TRUE),
);
];
\Drupal::logger('phpmailer')->error($output, $arguments);
return FALSE;
}
......
......@@ -20,45 +20,45 @@ class PHPMailerUnitTest extends UnitTestCase {
*/
function testAddressParser() {
// Set up various test addresses according to RFC 5322.
$this->addresses = array(
$this->addresses = [
// addr-spec.
array(
[
'mail' => 'user-1@domain.tld',
'name' => ''
),
],
// Invalid but supported angle-addr without preceding display-name.
'<user-2@domain.tld>' => array(
'<user-2@domain.tld>' => [
'mail' => 'user-2@domain.tld',
'name' => ''
),
],
// Unquoted atom name-addr.
'John Doe <user-3@domain.tld>' => array(
'John Doe <user-3@domain.tld>' => [
'mail' => 'user-3@domain.tld',
'name' => 'John Doe'
),
],
// Quoted atom name-addr.
'"John Doe" <user-4@domain.tld>' => array(
'"John Doe" <user-4@domain.tld>' => [
'mail' => 'user-4@domain.tld',
'name' => 'John Doe'
),
],
// name-addr with a quoted-string in display-name.
array(
[
'mail' => 'user-5@domain.tld',
'name' => 'John "The Dude" Doe'
),
],
// name-addr with a quoted-string and comma in display-name.
array(
[
'mail' => 'user-6@domain.tld',
'name' => 'John "The Dude" Doe (Foo, Bar)'
),
],
// name-addr containing non-ASCII chars in display-name.
array(
[
'mail' => 'user-7@domain.tld',
'name' => 'Jöhn "The Düde" Döe'
),
);
],
];
$all = array();
$all = [];
// Validate each address format is correctly parsed.
foreach ($this->addresses as $test => $address) {
if (is_numeric($test)) {
......@@ -71,7 +71,7 @@ class PHPMailerUnitTest extends UnitTestCase {
}
}
$result = phpmailer_parse_address($test);
$this->assertEqual($result[0], $address, t('Successfully extracted %email, %name from %address.', array('%email' => $result[0]['mail'], '%name' => $result[0]['name'] ? $result[0]['name'] : '(blank)', '%address' => $test)), 'PHPMailer');
$this->assertEqual($result[0], $address, t('Successfully extracted %email, %name from %address.', ['%email' => $result[0]['mail'], '%name' => $result[0]['name'] ? $result[0]['name'] : '(blank)', '%address' => $test]), 'PHPMailer');
$all[] = $test;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment