You are here

public function HtmlTest::testCleanCssIdentifier in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/Utility/HtmlTest.php \Drupal\Tests\Component\Utility\HtmlTest::testCleanCssIdentifier()
  2. 9 core/tests/Drupal/Tests/Component/Utility/HtmlTest.php \Drupal\Tests\Component\Utility\HtmlTest::testCleanCssIdentifier()

Tests the Html::cleanCssIdentifier() method.

@dataProvider providerTestCleanCssIdentifier

@covers ::cleanCssIdentifier

Parameters

string $expected: The expected result.

string $source: The string being transformed to an ID.

array|null $filter: (optional) An array of string replacements to use on the identifier. If NULL, no filter will be passed and a default will be used.

File

core/tests/Drupal/Tests/Component/Utility/HtmlTest.php, line 46

Class

HtmlTest
Tests \Drupal\Component\Utility\Html.

Namespace

Drupal\Tests\Component\Utility

Code

public function testCleanCssIdentifier($expected, $source, $filter = NULL) {
  if ($filter !== NULL) {
    $this
      ->assertSame($expected, Html::cleanCssIdentifier($source, $filter));
  }
  else {
    $this
      ->assertSame($expected, Html::cleanCssIdentifier($source));
  }
}