You are here

function DrupalHTMLIdentifierTestCase::testDrupalCleanCSSIdentifier in SimpleTest 7

Tests that drupal_clean_css_identifier() cleans the identifier properly.

File

tests/common.test, line 660
Tests for common.inc functionality.

Class

DrupalHTMLIdentifierTestCase
Test for cleaning HTML identifiers.

Code

function testDrupalCleanCSSIdentifier() {

  // 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 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 identifier.
  $this
    ->assertIdentical(drupal_clean_css_identifier('invalid !"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ identifier', array()), 'invalididentifier', t('Strip invalid characters.'));
}