You are here

public function CleanMarkupApiTestCase::testGetHtmlWrapperElements in Clean Markup 7.2

Test the _clean_markup_get_html_wrapper_elements() function.

File

./clean_markup.test, line 38
Tests for the Clean Markup module.

Class

CleanMarkupApiTestCase
Tests the common Clean Markup functionality.

Code

public function testGetHtmlWrapperElements() {
  $expected_elements = array(
    'address',
    'article',
    'aside',
    'blockquote',
    'caption',
    'details',
    'dd',
    'dialog',
    'div',
    'dl',
    'dt',
    'fieldset',
    'figcaption',
    'figure',
    'footer',
    'h1',
    'h2',
    'h3',
    'h4',
    'h5',
    'h6',
    'p',
    'header',
    'li',
    'menu',
    'nav',
    'ol',
    'section',
    'span',
    'td',
    'th',
    'ul',
  );
  $elements_with_nowrapper = _clean_markup_get_html_wrapper_elements(TRUE);
  $elements_default = _clean_markup_get_html_wrapper_elements();

  // Check that CLEAN_MARKUP_NO_ELEMENT is added when asked, but not by
  // default.
  $this
    ->assertTrue(array_key_exists(CLEAN_MARKUP_NO_ELEMENT, $elements_with_nowrapper), 'No wrapper element available when requested.');
  $this
    ->assertFalse(array_key_exists(CLEAN_MARKUP_NO_ELEMENT, $elements_default), 'No wrapper element not available by default.');

  // Check that each of the elements we expect are in the array.
  foreach ($expected_elements as $expected_element) {
    $this
      ->assertTrue(array_key_exists($expected_element, $elements_default), $expected_element . ' is in the array.');
  }

  // Check that there are no extra elements in the array.
  $this
    ->assertEqual(count($elements_default), count($expected_elements), 'No unexpected elements in the array.');
  $this
    ->assertEqual(count($elements_with_nowrapper), count($elements_default) + 1, 'Elements with no wrapper is only one element larger than default.');
}