Commit 547a1a0d authored by alexpott's avatar alexpott

Issue #2358995 by rpayanm, JeroenT, Alienpruts, gaurav.pahuja,...

Issue #2358995 by rpayanm, JeroenT, Alienpruts, gaurav.pahuja, er.pushpinderrana | Les Lim: Remove usage of drupal_wrap_mail().
parent 3b945fe2
......@@ -53,8 +53,8 @@ public function format(array $message);
* - subject: Subject of the email to be sent. This must not contain any
* newline characters, or the mail may not be sent properly.
* - body: Message to be sent. Accepts both CRLF and LF line-endings.
* Email bodies must be wrapped. You can use drupal_wrap_mail() for
* smart plain text wrapping.
* Email bodies must be wrapped. For smart plain text wrapping you can use
* \Drupal\Core\Mail\MailFormatHelper::wrapMail() .
* - headers: Associative array containing all additional mail headers not
* defined by one of the other parameters. PHP's mail() looks for Cc and
* Bcc headers and sends the mail to addresses in these headers too.
......
......@@ -38,7 +38,7 @@ public function format(array $message) {
// Convert any HTML to plain-text.
$message['body'] = MailFormatHelper::htmlToText($message['body']);
// Wrap the mail body for sending.
$message['body'] = drupal_wrap_mail($message['body']);
$message['body'] = MailFormatHelper::wrapMail($message['body']);
return $message;
}
......
......@@ -362,28 +362,31 @@ public function testVeryLongLineWrap() {
}
/**
* Tests that drupal_wrap_mail() removes trailing whitespace before newlines.
* Tests that trailing whitespace is removed before newlines.
*
* @see \Drupal\Core\Mail\MailFormatHelper::wrapMail()
*/
public function testRemoveTrailingWhitespace() {
$text = "Hi there! \nHerp Derp";
$mail_lines = explode("\n", drupal_wrap_mail($text));
$mail_lines = explode("\n", MailFormatHelper::wrapMail($text));
$this->assertNotEqual(" ", substr($mail_lines[0], -1), 'Trailing whitespace removed.');
}
/**
* Tests that drupal_wrap_mail() does not remove the trailing whitespace from
* Usenet style signatures.
* Tests that trailing whitespace from Usenet style signatures is not removed.
*
* RFC 3676 says, "This is a special case; an (optionally quoted or quoted and
* stuffed) line consisting of DASH DASH SP is neither fixed nor flowed."
*
* @see \Drupal\Core\Mail\MailFormatHelper::wrapMail()
*/
public function testUsenetSignature() {
$text = "Hi there!\n-- \nHerp Derp";
$mail_lines = explode("\n", drupal_wrap_mail($text));
$mail_lines = explode("\n", MailFormatHelper::wrapMail($text));
$this->assertEqual("-- ", $mail_lines[1], 'Trailing whitespace not removed for dash-dash-space signatures.');
$text = "Hi there!\n-- \nHerp Derp";
$mail_lines = explode("\n", drupal_wrap_mail($text));
$mail_lines = explode("\n", MailFormatHelper::wrapMail($text));
$this->assertEqual("--", $mail_lines[1], 'Trailing whitespace removed for incorrect dash-dash-space signatures.');
}
}
......@@ -17,7 +17,7 @@
class MailFormatHelperTest extends UnitTestCase {
/**
* Makes sure that drupal_wrap_mail() wraps the correct types of lines.
* @covers ::wrapMail
*/
public function testWrapMail() {
$delimiter = "End of header\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment