Error message

You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).

function DrupalHtmlToTextTestCase::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 DrupalHtmlToTextTestCase::assertHtmlToText()
DrupalHtmlToTextTestCase::testDrupalHtmlToTextArgs in modules/simpletest/tests/mail.test
Test $allowed_tags argument of drupal_html_to_text().
DrupalHtmlToTextTestCase::testDrupalHtmltoTextCollapsesWhitespace in modules/simpletest/tests/mail.test
Test that whitespace is collapsed.
DrupalHtmlToTextTestCase::testDrupalHtmlToTextParagraphs in modules/simpletest/tests/mail.test
Test that combinations of paragraph breaks, line breaks, linefeeds, and spaces are properly handled.
DrupalHtmlToTextTestCase::testFootnoteReferences in modules/simpletest/tests/mail.test
Test that footnote references are properly generated.
DrupalHtmlToTextTestCase::testHeaderSeparation in modules/simpletest/tests/mail.test
Test that headers are properly separated from surrounding text.

... See full list

File

modules/simpletest/tests/mail.test, line 204

Class

DrupalHtmlToTextTestCase
Unit tests for drupal_html_to_text().

Code

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}");
 }
}

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