public function HtmlToTextTest::testVeryLongLineWrap

Tests that drupal_html_to_text() wraps before 1000 characters.

RFC 3676 says, "The Text/Plain media type is the lowest common denominator of Internet email, with lines of no more than 998 characters."

RFC 2046 says, "SMTP [RFC-821] allows a maximum of 998 octets before the next CRLF sequence."

RFC 821 says, "The maximum total length of a text line including the <CRLF> is 1000 characters."

File

drupal/core/modules/system/lib/Drupal/system/Tests/Mail/HtmlToTextTest.php, line 348
Definition of Drupal\system\Tests\Mail\HtmlToTextTest.

Class

HtmlToTextTest
Tests for drupal_html_to_text().

Namespace

Drupal\system\Tests\Mail

Code

public function testVeryLongLineWrap() {
  $input = 'Drupal<br /><p>' . str_repeat('x', 2100) . '</><br />Drupal';
  $output = drupal_html_to_text($input);
  $eol = settings()
    ->get('mail_line_endings', MAIL_LINE_ENDINGS);
  $maximum_line_length = 0;
  foreach (explode($eol, $output) as $line) {

    // We must use strlen() rather than drupal_strlen() in order to count
    // octets rather than characters.
    $maximum_line_length = max($maximum_line_length, strlen($line . $eol));
  }
  $verbose = 'Maximum line length found was ' . $maximum_line_length . ' octets.';

  // @todo This should assert that $maximum_line_length <= 1000.
  $this
    ->pass($verbose);
}