You are here

function DrupalHtmlToTextTestCase::testDrupalHtmlToTextArgs in Drupal 7

Test $allowed_tags argument of drupal_html_to_text().

File

modules/simpletest/tests/mail.test, line 315
Test the Drupal mailing system.

Class

DrupalHtmlToTextTestCase
Unit tests for drupal_html_to_text().

Code

function testDrupalHtmlToTextArgs() {

  // The second parameter of drupal_html_to_text() overrules the allowed tags.
  $this
    ->assertHtmlToText('Drupal <b>Drupal</b> Drupal', "Drupal *Drupal* Drupal\n", 'Allowed <b> tag found', array(
    'b',
  ));
  $this
    ->assertHtmlToText('Drupal <h1>Drupal</h1> Drupal', "Drupal Drupal Drupal\n", 'Disallowed <h1> tag not found', array(
    'b',
  ));
  $this
    ->assertHtmlToText('Drupal <p><em><b>Drupal</b></em><p> Drupal', "Drupal Drupal Drupal\n", 'Disallowed <p>, <em>, and <b> tags not found', array(
    'a',
    'br',
    'h1',
  ));
  $this
    ->assertHtmlToText('<html><body>Drupal</body></html>', "Drupal\n", 'Unsupported <html> and <body> tags not found', array(
    'html',
    'body',
  ));
}