clean_markup.test in Clean Markup 7.2
Tests for the Clean Markup module.
File
clean_markup.testView source
<?php
/**
* @file
* Tests for the Clean Markup module.
*/
/**
* Tests the common Clean Markup functionality.
*/
class CleanMarkupApiTestCase extends DrupalUnitTestCase {
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'Clean Markup API test',
'description' => 'Tests the common Clean Markup functionality.',
'group' => 'Clean Markup',
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
// Include the module file so we have access to the functions we want to
// test.
drupal_load('module', 'clean_markup');
}
/**
* Test the _clean_markup_get_html_wrapper_elements() function.
*/
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.');
}
}
Classes
Name | Description |
---|---|
CleanMarkupApiTestCase | Tests the common Clean Markup functionality. |