You are here

public function HtmlTest::providerTestCleanCssIdentifier in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Component/Utility/HtmlTest.php \Drupal\Tests\Component\Utility\HtmlTest::providerTestCleanCssIdentifier()

Provides test data for testCleanCssIdentifier().

Return value

array Test data.

File

core/tests/Drupal/Tests/Component/Utility/HtmlTest.php, line 63
Contains \Drupal\Tests\Component\Utility\HtmlTest.

Class

HtmlTest
Tests \Drupal\Component\Utility\Html.

Namespace

Drupal\Tests\Component\Utility

Code

public function providerTestCleanCssIdentifier() {
  $id1 = 'abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789';
  $id2 = '¡¢£¤¥';
  $id3 = 'css__identifier__with__double__underscores';
  return array(
    // Verify that no valid ASCII characters are stripped from the identifier.
    array(
      $id1,
      $id1,
      array(),
    ),
    // Verify that valid UTF-8 characters are not stripped from the identifier.
    array(
      $id2,
      $id2,
      array(),
    ),
    // Verify that invalid characters (including non-breaking space) are stripped from the identifier.
    array(
      $id3,
      $id3,
    ),
    // Verify that double underscores are not stripped from the identifier.
    array(
      'invalididentifier',
      'invalid !"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ identifier',
      array(),
    ),
    // Verify that an identifier starting with a digit is replaced.
    array(
      '_cssidentifier',
      '1cssidentifier',
      array(),
    ),
    // Verify that an identifier starting with a hyphen followed by a digit is
    // replaced.
    array(
      '__cssidentifier',
      '-1cssidentifier',
      array(),
    ),
    // Verify that an identifier starting with two hyphens is replaced.
    array(
      '__cssidentifier',
      '--cssidentifier',
      array(),
    ),
    // Verify that passing double underscores as a filter is processed.
    array(
      '_cssidentifier',
      '__cssidentifier',
      array(
        '__' => '_',
      ),
    ),
  );
}