1 common.test CommonHTMLIdentifierTestCase::testBackdropCleanCSSIdentifier()

Tests that backdrop_clean_css_identifier() cleans the identifier properly.

File

core/modules/simpletest/tests/common.test, line 897
Tests for common.inc functionality.

Class

CommonHTMLIdentifierTestCase
Test for cleaning HTML identifiers.

Code

function testBackdropCleanCSSIdentifier() {
  // Verify that no valid ASCII characters are stripped from the identifier.
  $identifier = 'abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789';
  $this->assertIdentical(backdrop_clean_css_identifier($identifier, array()), $identifier, 'Verify valid ASCII characters pass through.');

  // Verify that valid UTF-8 characters are not stripped from the identifier.
  $identifier = '¡¢£¤¥';
  $this->assertIdentical(backdrop_clean_css_identifier($identifier, array()), $identifier, 'Verify valid UTF-8 characters pass through.');

  // Verify that invalid characters (including non-breaking space) are stripped from the identifier.
  $this->assertIdentical(backdrop_clean_css_identifier('invalid !"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ identifier', array()), 'invalididentifier', 'Strip invalid characters.');
}