function HtmlTest::testHtmlGetId

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Utility/HtmlTest.php \Drupal\Tests\Component\Utility\HtmlTest::testHtmlGetId()
  2. 8.9.x core/tests/Drupal/Tests/Component/Utility/HtmlTest.php \Drupal\Tests\Component\Utility\HtmlTest::testHtmlGetId()
  3. 10 core/tests/Drupal/Tests/Component/Utility/HtmlTest.php \Drupal\Tests\Component\Utility\HtmlTest::testHtmlGetId()

Tests the Html::getUniqueId() method.

@dataProvider providerTestHtmlGetId

@covers ::getId

Parameters

string $expected: The expected result.

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

File

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

Class

HtmlTest
Tests <a href="/api/drupal/core%21lib%21Drupal%21Component%21Utility%21Html.php/class/Html/11.x" title="Provides DOMDocument helpers for parsing and serializing HTML strings." class="local">\Drupal\Component\Utility\Html</a>.

Namespace

Drupal\Tests\Component\Utility

Code

public function testHtmlGetId($expected, $source) : void {
    Html::setIsAjax(FALSE);
    $this->assertSame($expected, Html::getId($source));
}

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