function HtmlTest::providerTestCleanCssIdentifier

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Component/Utility/HtmlTest.php \Drupal\Tests\Component\Utility\HtmlTest::providerTestCleanCssIdentifier()
  2. 10 core/tests/Drupal/Tests/Component/Utility/HtmlTest.php \Drupal\Tests\Component\Utility\HtmlTest::providerTestCleanCssIdentifier()
  3. 11.x 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 64

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.