function HtmlTest::testHtmlGetUniqueId

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

Tests the Html::getUniqueId() method.

@dataProvider providerTestHtmlGetUniqueId

@covers ::getUniqueId

Parameters

string $expected: The expected result.

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

bool $reset: (optional) If TRUE, reset the list of seen IDs. Defaults to FALSE.

File

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

Class

HtmlTest
Tests <a href="/api/drupal/core%21lib%21Drupal%21Component%21Utility%21Html.php/class/Html/9" 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 testHtmlGetUniqueId($expected, $source, $reset = FALSE) {
    if ($reset) {
        Html::resetSeenIds();
    }
    $this->assertSame($expected, Html::getUniqueId($source));
}

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