summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest/tests')
-rw-r--r--modules/simpletest/tests/common.test41
1 files changed, 24 insertions, 17 deletions
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index 35c8bf52f..fe37b416a 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -573,47 +573,54 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase {
}
/**
- * Test for drupal_add_css().
+ * Test for cleaning HTML identifiers.
*/
-class DrupalCSSIdentifierTestCase extends DrupalUnitTestCase {
+class DrupalHTMLIdentifierTestCase extends DrupalUnitTestCase {
public static function getInfo() {
return array(
- 'name' => 'CSS identifiers',
- 'description' => 'Test the functions drupal_html_class() and drupal_html_id() for expected behavior',
+ 'name' => 'HTML identifiers',
+ 'description' => 'Test the functions drupal_html_class(), drupal_html_id() and drupal_clean_css_identifier() for expected behavior',
'group' => 'System',
);
}
/**
- * Tests that drupal_html_class() cleans the class name properly.
+ * Tests that drupal_clean_css_identifier() cleans the identifier properly.
*/
function testDrupalCleanCSSIdentifier() {
- // Verify that no valid ASCII characters are stripped from the class name.
- $class = 'abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789';
- $this->assertIdentical(drupal_clean_html_identifier($class, array()), $class, t('Verify valid ASCII characters pass through.'));
+ // Verify that no valid ASCII characters are stripped from the identifier.
+ $identifier = 'abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789';
+ $this->assertIdentical(drupal_clean_css_identifier($identifier, array()), $identifier, t('Verify valid ASCII characters pass through.'));
- // Verify that no valid UTF-8 characters are stripped from the class name.
- $class = '¡¢£¤¥';
- $this->assertIdentical(drupal_clean_html_identifier($class, array()), $class, t('Verify valid UTF-8 characters pass through.'));
+ // Verify that valid UTF-8 characters are not stripped from the identifier.
+ $identifier = '¡¢£¤¥';
+ $this->assertIdentical(drupal_clean_css_identifier($identifier, array()), $identifier, t('Verify valid UTF-8 characters pass through.'));
- // Verify that invalid characters (including non-breaking space) are stripped from the class name.
- $this->assertIdentical(drupal_clean_html_identifier('invalid !"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ class', array()), 'invalidclass', t('Strip invalid characters.'));
+ // Verify that invalid characters (including non-breaking space) are stripped from the identifier.
+ $this->assertIdentical(drupal_clean_css_identifier('invalid !"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ identifier', array()), 'invalididentifier', t('Strip invalid characters.'));
}
/**
* Tests that drupal_html_class() cleans the class name properly.
*/
- function testDrupalCSSClass() {
+ function testDrupalHTMLClass() {
// Verify Drupal coding standards are enforced.
$this->assertIdentical(drupal_html_class('CLASS NAME_[Ü]'), 'class-name--ü', t('Enforce Drupal coding standards.'));
}
/**
- * Tests that drupal_html_id() cleans the id name properly.
+ * Tests that drupal_html_id() cleans the ID properly.
*/
- function testDrupalCSSId() {
+ function testDrupalHTMLId() {
+ // Verify that letters, digits, and hyphens are not stripped from the ID.
+ $id = 'abcdefghijklmnopqrstuvwxyz-0123456789';
+ $this->assertIdentical(drupal_html_id($id), $id, t('Verify valid characters pass through.'));
+
+ // Verify that invalid characters are stripped from the ID.
+ $this->assertIdentical(drupal_html_id('invalid,./:@\\^`{Üidentifier'), 'invalididentifier', t('Strip invalid characters.'));
+
// Verify Drupal coding standards are enforced.
- $this->assertIdentical(drupal_html_id('ID NAME_[Ü]'), 'id-name--ü', t('Enforce Drupal coding standards.'));
+ $this->assertIdentical(drupal_html_id('ID NAME_[1]'), 'id-name--1', t('Enforce Drupal coding standards.'));
// Reset the static cache so we can ensure the unique id count is at zero.
drupal_static_reset('drupal_html_id');