1.20.x mail.test | BackdropHtmlToTextTestCase::assertHtmlToText($html, $text, $message, $allowed_tags = NULL) |
Helper function for testing backdrop_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 backdrop_html_to_text().
File
- modules/
simpletest/ tests/ mail.test, line 113 - Test the Backdrop mailing system.
Class
- BackdropHtmlToTextTestCase
- Unit tests for backdrop_html_to_text().
Code
function assertHtmlToText($html, $text, $message, $allowed_tags = NULL) {
preg_match_all('/<([a-z0-6]+)/', backdrop_strtolower($html), $matches);
$tested_tags = implode(', ', array_unique($matches[1]));
$message .= ' (' . $tested_tags . ')';
$result = backdrop_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");
}
}