protected function HtmlToTextTest::assertHtmlToText

Helper function for testing drupal_html_to_text().

Parameters

$html: The source HTML string to be converted.

$text: The expected result of converting $html to text.

$message: A text message to display in the assertion message.

$allowed_tags: (optional) An array of allowed tags, or NULL to default to the full set of tags supported by drupal_html_to_text().

6 calls to HtmlToTextTest::assertHtmlToText()
HtmlToTextTest::testDrupalHtmlToTextArgs in drupal/core/modules/system/lib/Drupal/system/Tests/Mail/HtmlToTextTest.php
Test $allowed_tags argument of drupal_html_to_text().
HtmlToTextTest::testDrupalHtmltoTextCollapsesWhitespace in drupal/core/modules/system/lib/Drupal/system/Tests/Mail/HtmlToTextTest.php
Test that whitespace is collapsed.
HtmlToTextTest::testDrupalHtmlToTextParagraphs in drupal/core/modules/system/lib/Drupal/system/Tests/Mail/HtmlToTextTest.php
Test that combinations of paragraph breaks, line breaks, linefeeds, and spaces are properly handled.
HtmlToTextTest::testFootnoteReferences in drupal/core/modules/system/lib/Drupal/system/Tests/Mail/HtmlToTextTest.php
Test that footnote references are properly generated.
HtmlToTextTest::testHeaderSeparation in drupal/core/modules/system/lib/Drupal/system/Tests/Mail/HtmlToTextTest.php
Test that headers are properly separated from surrounding text.

... See full list

File

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

Class

HtmlToTextTest
Tests for drupal_html_to_text().

Namespace

Drupal\system\Tests\Mail

Code

protected function assertHtmlToText($html, $text, $message, $allowed_tags = NULL) {
  preg_match_all('/<([a-z0-6]+)/', drupal_strtolower($html), $matches);
  $tested_tags = implode(', ', array_unique($matches[1]));
  $message .= ' (' . $tested_tags . ')';
  $result = drupal_html_to_text($html, $allowed_tags);
  $pass = $this
    ->assertEqual($result, $text, check_plain($message));
  $verbose = 'html = <pre>' . $this
    ->stringToHtml($html) . '</pre><br />' . 'result = <pre>' . $this
    ->stringToHtml($result) . '</pre><br />' . 'expected = <pre>' . $this
    ->stringToHtml($text) . '</pre>';
  $this
    ->verbose($verbose);
  if (!$pass) {
    $this
      ->pass("Previous test verbose info:<br />{$verbose}");
  }
}