function HtmlToTextTest::testRemoveTrailingWhitespace

Same name and namespace in other branches
  1. 8.9.x core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php \Drupal\Tests\system\Functional\Mail\HtmlToTextTest::testRemoveTrailingWhitespace()
  2. 10 core/modules/system/tests/src/Unit/Mail/HtmlToTextTest.php \Drupal\Tests\system\Unit\Mail\HtmlToTextTest::testRemoveTrailingWhitespace()
  3. 11.x core/modules/system/tests/src/Unit/Mail/HtmlToTextTest.php \Drupal\Tests\system\Unit\Mail\HtmlToTextTest::testRemoveTrailingWhitespace()

Tests that trailing whitespace is removed before newlines.

See also

\Drupal\Core\Mail\MailFormatHelper::wrapMail()

File

core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php, line 352

Class

HtmlToTextTest
Tests for <a href="/api/drupal/core%21lib%21Drupal%21Core%21Mail%21MailFormatHelper.php/function/MailFormatHelper%3A%3AhtmlToText/9" title="Transforms an HTML string into plain text, preserving its structure." class="local">\Drupal\Core\Mail\MailFormatHelper::htmlToText</a>().

Namespace

Drupal\Tests\system\Functional\Mail

Code

public function testRemoveTrailingWhitespace() {
    $text = "Hi there! \nEarth";
    $mail_lines = explode("\n", MailFormatHelper::wrapMail($text));
    $this->assertNotEquals(" ", substr($mail_lines[0], -1), 'Trailing whitespace removed.');
}

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